Answered step by step
Verified Expert Solution
Question
1 Approved Answer
DateDemo Class import java.util.Scanner; public class DateDemo { public static void main ( String [ ] args ) { Scanner in = new Scanner (
DateDemo Class
import java.util.Scanner;
public class DateDemo
public static void mainString args
Scanner in new ScannerSystemin;
Prompt the user for the first day of class.
Read a string in the format mmddyyyy and parse the string into integers
representing the month, day and year.
System.out.printEnter the first day of class ;
String line innextLine;
String nums line.split;
int m Integer.parseIntnums;
int d Integer.parseIntnums;
int y Integer.parseIntnums;
Do the same thing for the last day of class
Construct two objects of the Date class for the first day of class
and the last day of class.
Call the setDate method on each of the two objects to set the values
of their instance variables using the data that was entered.
Call the getWeekDay method on each of the two objects to get the name of
the weekday as a string and store it in a string variable.
Call the getMonth method on each of the two objects to get the name of
the month as a string and store it in a string variable.
Print a blank line Systemout.println; and then write two println
statements to print the first day of class and the last day of class
as shown in the output on the assgnment sheet. When you write the two
println statements, use the string variables defined above for the name
of the weekday and the name of the month, and call the getDay and getYear
methods on the objects to get the day and year as integers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started