Question: What is wrong with this code?? Exception in thread main java.lang.Error: Unresolved compilation problems: The method getDayOfWeek() is undefined for the type Date The method
What is wrong with this code??
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method getDayOfWeek() is undefined for the type Date
The method advanceTo(Date) is undefined for the type Date
at DateClient.main(DateClient.java:22)
import java.util.*;
public class DateClient {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
System.out.println("What is today's date(month day year)? ");
int month = userInput.nextInt();
int day = userInput.nextInt();
int year = userInput.nextInt();
Date TodayDate = new Date(year, month, day);
System.out.print("What is your birthday(month, day, year)?");
month = userInput.nextInt();
day = userInput.nextInt();
year = userInput.nextInt();
Date bDate = new Date(year,month,day);
System.out.print("You were born on " + bDate+","+" which was a "+bDate.getDayOfWeek());
if(bDate.isLeapYear()){
System.out.println(" "+year+" was a leap year.");
}
System.out.println("You are "+bDate.advanceTo(TodayDate)+" days old.");
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
