Write a program to generate the entire calendar for one year. The program must get two values from the user: (1) the year and (2)
Write a program to generate the entire calendar for one year. The program must get two values from the user: (1) the year and (2) the day of the week for January 1st of that year. The year, which should be positive, is needed to check for and handle leap years 1. The day of the week for January 1st is needed so that you know where to start the calendar. The user should enter 0 for Sunday, 1 for Monday, ... or 6 for Saturday. As always, you need to validate the user's input. To actually print the calendar, you must use a single method that prints out the calendar for one month and then call this function 12 times from main(), once for each month in the year. To check for a leap year you will need to write another method that takes the year as a parameter and returns true if it’s a leap year, or false otherwise. Stubs (i.e. method signatures without any code) for both of these methods have been provided for you. The calendar should be printed in the form below. In this example, January starts on a Saturday (day 6).
Note that February starts on a Tuesday in this example because January ended on a Monday.
January
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
February
1 2 3 4 5
6 7 8 9 10
11 ...
(a base code has been provided to start with)
package edu.wit.cs.comp1000;
// TODO: document this class
public class PA6a {
/**
* Error to output if year is not positive
*/
static final String E_YEAR = "The year must be positive!";
/**
* Error to output if the day is not between 0 and 6
*/
static final String E_DAY = "The day of January 1st must be between 0 and 6!";
/**
* Determines if an input is a leap year
*
* @param year year in question
* @ereturn true if a leap year
*/
public static boolean isLeapYear(int year) {
return false; // TODO: replace with your code
}
/**
* Outputs a month to the console
*
* @param month title
* @param startDay 0=Sunday ... 6=Saturday
* @param numDays number of days in the month
* @return day of the week of the last day of the month
*/
public static int printMonth(String month, int startDay, int numDays) {
return 0; // TODO: replace with your code
}
/**
* Program execution point:
* input year, day of the week (0-6) of january 1
* output calendar for that year
*
* @param args command-line arguments (ignored)
*/
public static void main(String[] args) {
// TODO: write your code here
}
}
Step by Step Solution
3.46 Rating (146 Votes )
There are 3 Steps involved in it
Step: 1
Please let me know if you need more information PA6ajava import javautilScanner public class PA6a Er...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