I'm lost on where to start on this one. I have the following code
import java.util.Scanner;
public class Age {
/**
* @param args
*/
public static void main(String[] args) {
int birthYear;
int currentYear;
int age;
Scanner inputObject = new Scanner(System.in);
System.out.print("Enter the year of your birth ");
birthYear = inputObject.nextInt();
System.out.print("Enter the year for which you wish to know your age ");
currentYear = inputObject.nextInt();
age = currentYear - birthYear;
System.out.println("You are " + age + " Years Old");
System.out.println("You are " + age*12 + " Months Old");
System.out.println("You are " + age*365 + " Days Old");
}
}
I need to take that code and rewrite it to use an age class object to handle to calculation of the age and displaying of the results. Obviously, I understand that these parts
birthYear = inputObject.nextInt();
currentYear = inputObject.nextInt();
age = currentYear - birthYear;
System.out.println("You are " + age + " Years Old");
System.out.println("You are " + age*12 + " Months Old");
System.out.println("You are " + age*365 + " Days Old");
need to be included in a different class. I'm not looking for an answer, but maybe just some advice on what is expected since I am not even completely sure what is even meant by a class object. Could someone clarify this for me?Thanks in advance!!

New Topic/Question
Reply




MultiQuote








|