Problem

Write a program that determines the number of days in a given semester. Input to the pro...

Write a program that determines the number of days in a given semester. Input to the program is the year, month, and day information of the first and the last days of a semester. Hint: Create GregorianCalendar objects for the start and end dates of a semester and manipulate their DAY_OF_YEAR data.

Step-by-Step Solution

Solution 1

Program Plan:

- Import the util package that contains Scanner and Gregoriancalendar classes.

- The Scanner class object reads console input entered by the user. The Gregoriancalendar class object stores the values of starting and ending dates of the semester.

- Define main class MainClass and initialize main () function.

- Declare integer variables and objects of Scanner and Gregoriancalendar classes.

- The object lineSeparator uses the getproperty () method to read for a new line.

- Prompt user to enter start and end dates of the semester.

- Calculate the number of days in the semester.

- Use method println() of System class to display the results.

Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT