assigments
This commit is contained in:
		
							
								
								
									
										21
									
								
								assignments/assignment1/fibonacci.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								assignments/assignment1/fibonacci.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | import java.util.Scanner; | ||||||
|  |  | ||||||
|  | public class fibonacci { | ||||||
|  |     public static void main(String args[]) { | ||||||
|  |         int a = 0; | ||||||
|  |         int b = 1; | ||||||
|  |         int count = 1; | ||||||
|  |         int userInput; | ||||||
|  |         Scanner scan = new Scanner(System.in); | ||||||
|  |         System.out.println("Enter positive number!"); | ||||||
|  |         userInput = scan.nextInt(); | ||||||
|  |  | ||||||
|  |             while (userInput >= b) { | ||||||
|  |             int c = a + b; | ||||||
|  |             a = b; | ||||||
|  |             b = c; | ||||||
|  |             ++count; | ||||||
|  |             } | ||||||
|  |         System.out.println("Index is : "+count); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										17
									
								
								assignments/assignment1/leapYear.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								assignments/assignment1/leapYear.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | |||||||
|  | import java.util.Scanner; | ||||||
|  |  | ||||||
|  | public class leapYear { | ||||||
|  |     public static void main(String args[]) { | ||||||
|  |         Scanner scan = new Scanner(System.in); | ||||||
|  |         System.out.println("Enter year!"); | ||||||
|  |         int year = scan.nextInt(); | ||||||
|  |  | ||||||
|  |         if (year%4 == 0 || year%100 == 0 && year%400 == 0 && year > 1581) { | ||||||
|  |             System.out.println("The year "+year+" is a leap year!"); | ||||||
|  |         } else if (year < 1582){ | ||||||
|  |             System.out.println("ENTER MORE THAN YEAR 1581!"); | ||||||
|  |         } else { | ||||||
|  |             System.out.println("The year: "+year+" isn't leap year"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										13
									
								
								assignments/assignment1/number.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								assignments/assignment1/number.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | import java.util.Scanner; | ||||||
|  |  | ||||||
|  | public class number { | ||||||
|  |     public static void main(String args[]) { | ||||||
|  |         Scanner scan = new Scanner(System.in); | ||||||
|  |  | ||||||
|  |         System.out.println("Enter your phone number in 10 DIGIT!"); | ||||||
|  |         String phone = scan.next(); | ||||||
|  |         System.out.println("Full : ("+phone.substring(0,3)+")"+phone.substring(3,6)+"-"+phone.substring(6,10)); | ||||||
|  |         System.out.println("Local : "+phone.substring(3,6)+"-"+phone.substring(6,10)); | ||||||
|  |         System.out.println("Campus : "+phone.substring(5,6)+"-"+phone.substring(6,10)); | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user