Answered step by step
Verified Expert Solution
Link Copied!

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 main(String[] args)
{
Scanner in = new Scanner(System.in);
// Prompt the user for the first day of class.
// Read a string in the format mm/dd/yyyy and parse the string into 3 integers
// representing the month, day and year.
System.out.print("Enter the first day of class ->");
String line = in.nextLine();
String[] nums = line.split("/");
int m1= Integer.parseInt(nums[0]);
int d1= Integer.parseInt(nums[1]);
int y1= Integer.parseInt(nums[2]);
// 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 (System.out.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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions