hi. here is my program for y2k detector
import java.util.Scanner;
class yDetector{
public static void main(String args[]) {
Scanner myScanner = new Scanner (System.in);
int age;
int year;
int total;
System.out.println("Enter your age ");
age = myScanner.nextInt();
System.out.println("Enter the year ");
year = myScanner.nextInt();
if ( year == 00) {
year = 100;
total = year - age;
System.out.println(" Your age :" + total);
}
else {
total = year - age;
System.out.println("your age " + total);
}
}
}
This program works fine only for 00 for eg;
Enter your age
29
Enter the year
00
Your age :71
Now my problem is what if a user enters 01 or 02 or 03 what kind of condition can i make so then it calculates the rite age any clues ?
i know i can do this easily if the year and age should be 4 digits like 1999 and year 2005 but i want the user to enter 2 digits for the age and year
Message was edited by:
fastmike
Message was edited by:
fastmike