Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class HW289{
- public static Scanner reader = new Scanner(System.in);
- public static void main(String[]args){
- //Q1
- System.out.println("Enter wins and losess: ");
- int wins = reader.nextInt();
- int losess = reader.nextInt();
- if(wins > 6 && losess < 5) System.out.println("Advanced to the national competition");
- else System.out.println("Didn't advance to the national competition");
- //Q2
- System.out.println("Enter the number of years of education and matriculation grade: ");
- int years = reader.nextInt();
- int grade = reader.nextInt();
- if ((years > 12 && grade > 90) || years > 15) System.out.println("Pass");
- else System.out.println("Fail");
- //Q3
- System.out.println("Enter 3 numbers:");
- int num1 = reader.nextInt();
- int num2 = reader.nextInt();
- int num3 = reader.nextInt();
- if ( num1 == num2 && num2 == num3) System.out.println("The numbers are equal");
- else if (num1 == num2 ^ num2 == num3 ^ num3 == num1) System.out.println("2 numbers are equal");
- else System.out.println("The numbers aren't equal");
- //Q4
- System.out.println("Enter 2 numbers: ");
- int n1 = reader.nextInt();
- int n2 = reader.nextInt();
- int n3 = reader.nextInt();
- if((n1+n2 > n3) && (n2+n3 > n1) && (n3+n1 > n2)){
- if (n1 == n2 && n2 == n3) System.out.println("Equilateral triangle");
- else if(n1 == n2 ^ n2 == n3 ^ n3 == n1) System.out.println("An isosceles triangle");
- else System.out.println("Triangle");
- }
- else System.out.println("Not a triangle");
- //Q5
- System.out.println("Insert ID card, marital status, room density and age: ");
- int id = reader.nextInt();
- int family = reader.nextInt();
- int ppr = reader.nextInt();//person per room
- int age = reader.nextInt();
- if ((family == 1 && ppr == 0) || (family == 1 && ppr > 3) || (family == 0 && age > 34)) System.out.println("Eentitled to an apartment");
- else System.out.println("Not entitled to an apartment");
- //Q6
- System.out.println("Insert year, month and day: ");
- int year = reader.nextInt();
- int month = reader.nextInt();
- int day = reader.nextInt();
- if(month < 1 || month > 12 || day < 0)// בדיקת תקינות התאריך
- {System.out.println("There is an error in the date you entered");}
- // סופי חודשים
- else if((month == 1 || month == 4 || month == 6 || month == 9 || month == 11)&&(day == 30) || (month == 3 || month == 5 || month == 7 || month == 8 || month == 10)&&(day == 31)) // סוף כל החודשים לא כולל 2 ו-12
- {month++; day = 1;}
- else if(month == 2 && (year % 4 != 0 || (year % 4 == 0 && year % 400 == 0) && day == 28) || (year % 4 == 0 && year % 400 != 0 && day == 29))
- {month++; day = 1;}// סוף חודש פבואר
- else if(month == 12 && day == 31) {month = 1; day = 1; year++;}// סוף שנה
- // בדיקת תקינות התאריך
- else if((month == 1 || month == 4 || month == 6 || month == 9 || month == 11)&&(day > 31) || (month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)&&(day > 30))
- {System.out.println("There is an error in the date you entered");}
- else if(month == 2 && (year % 4 != 0 || (year % 4 == 0 && year % 400 == 0) && day > 28) || (year % 4 == 0 && year % 400 != 0 && day > 29))
- {System.out.println("There is an error in the date you entered");}
- else if(month == 12 && day == 31)
- {System.out.println("There is an error in the date you entered");}
- //אמצע חודש
- else {day++;}
- System.out.println(year+"/"+month+"/"+day);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement