Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program will print a calendar for a given month. The user will input the following: The month (1 to 12) The year (1800 to

image text in transcribed

This program will print a calendar for a given month. The user will input the following: The month (1 to 12) The year (1800 to 2200) The day of the week (0 = Sunday, 1 Monday, etc.) that the 1st falls on Use the validation code you wrote in #1 to validate the input. Name your project Calendar and create a source file called Calendar.java The calendar will look like this: OCTOBER 2018 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 One algorithm to print this would be to a) First print the name of the month, then the Day headers b) On the next line, print spaces for days leading up to the first of the month c) Print the current day of the month, increment the day of the month d) If we've printed the last day of the week (Saturday, day 6), print a new line e) If we've printed the last day of the month, print a new line and exit the loop f) Loop back to step c. Hints Use if-else if else or switch-case to set the name of the month and the number of days Use printf to make the columns line up You can use either a while or for loop You can either track what day of the week you are printing, or use the mod operator (96) to determine if it's Saturday It is a leap year if the year is evenly divisible by 4, unless it ends in 00. If the year is evenly divisible by 100, then it must be divisible by 400 to be a leap year. For example, 1900 was not a leap year but 2000 was a leap year

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago