Question: This program will print a calendar for a given month. The user will input the following: the question says use the validatin code from #1
This program will print a calendar for a given month. The user will input the following:

the question says use the validatin code from #1 to valid the input for the calendar, so here is my code for the first program:
/**
* This program calculates average test score
*/
import java.util.Scanner;
/**
* @author anon
*
*/
public class AverageTestScore {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("AverageTestScore by anon");
Scanner in = new Scanner(System.in);
System.out.println("Enter the test scores below, use -1 to terminate");
int count = 0, input = 0;
float sum = 0, average = 0;
while (input != -1) {
try {
System.out.println("Enter test score: ");
input = in.nextInt();
}catch (NumberFormatException e) {
System.out.println("Please enter an integer");
continue;
}if (input 100) {
if (input != -1)
System.out.println("Test scores must be between 0 and 100");
}else {
sum += input;
count++;
}
}if (sum > 0) {
average = (sum/count);
System.out.println("Average score = " + average);
System.out.println("Number of tests = " + count);
}else {
System.out.println("No data.");
}
in.close();
}
}
2. 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 (0Sunday, 1 Monday, etc.) that the 1 Use the validation code you wrote in #1 to validate the input. falls on The calendar will look like this: OCTOBER 2018 S M T W T F S 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 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. 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
