Question: Write a program that, given a month and year, prints a calendar, such as To find out the weekday of the first day of the

Write a program that, given a month and year, prints a calendar, such as

June 2016 Su Mo Tu We Th Fr Sa 1 2 3

To find out the weekday of the first day of the month, call 

int weekday = java.time.LocalDate.of(year, month, 1).getDayOfWeek().getValue();
// 1 = Monday, 2 = Tuesday, ..., 7 = Sunday

Make a helper function to print the header and a helper function to print each row.

June 2016 Su Mo Tu We Th Fr Sa 1 2 3 4 5 67 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Step by Step Solution

3.37 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilScanner public class PrintCalendar sets the width of each cell in the calendar privat... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Concepts Late Objects Questions!