Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package bg.unwe;
- import java.util.Scanner;
- public class Birthday {
- public static void main(String[] args) {
- Scanner scanner=new Scanner(System.in);
- System.out.println("Your birthday is: ");
- System.out.print("Year: ");
- int year=Integer.parseInt(scanner.nextLine());
- System.out.print("Month: ");
- int month=Integer.parseInt(scanner.nextLine());
- System.out.print("Day: ");
- int day=Integer.parseInt(scanner.nextLine());
- if (month<1&&month>12) {
- System.out.println("Wrong month!");
- }else if(day<1&&day>31)
- System.out.println("Wrong day!");
- {
- }
- System.out.println("Today is: ");
- System.out.print("Year: ");
- int yeart=Integer.parseInt(scanner.nextLine());
- System.out.print("Month: ");
- int montht=Integer.parseInt(scanner.nextLine());
- System.out.print("Day: ");
- int dayt=Integer.parseInt(scanner.nextLine());
- if (montht<1&&month>12) {
- System.out.println("Wrong month!");
- }else if(dayt<1&&day>31)
- System.out.println("Wrong day!");
- {
- }
- int age;
- if (month>=montht) {
- age=(yeart-year)-1;
- System.out.printf("You are %d years old.\n", age);
- if (age<0) {
- System.out.println("You haven't been born yet");
- }else if(age>0&&age<=3){
- System.out.println("You are a baby");
- }else if(age>3&&age<=13){
- System.out.println("You are a child");
- }else if(age>13&&age<=19){
- System.out.println("You are a teenager");
- }else if(age>19&&age>60){
- System.out.println("You are a an old person");
- }else if(age>60&&age>90){
- System.out.println("You are a vey old person");
- }else if(age>90&&age>130){
- System.out.println("Are you sure you've entered correct information?");
- }else if(month<montht){
- age=yeart-year;
- System.out.printf("You are %d years old.\n", age);
- if (age<0) {
- System.out.println("You haven't been born yet");
- }else if(age>0&&age<=3){
- System.out.println("You are a baby");
- }else if(age>3&&age<=13){
- System.out.println("You are a child");
- }else if(age>13&&age<=19){
- System.out.println("You are a teenager");
- }else if(age>19&&age>60){
- System.out.println("You are a an old person");
- }else if(age>60&&age>90){
- System.out.println("You are a vey old person");
- }else if(age>90&&age>130){
- }
- }
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement