Question: Write a program that produces calendars as output. Your program should have a method that outputs a single months calendar like the one below, given

Write a program that produces calendars as output. Your program should have a method that outputs a single month’s calendar like the one below, given parameters to specify how many days are in the month and what the date of the first Sunday is in that month. In the month shown below, these values are 31 and 6, respectively.

Sun Mon Tue Wed Thu Fri Sat 2 3 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 tricky part of this program is making the various columns line up properly with proper widths. We will learn better ways of formatting output in the next chapter. For now, you may copy the following helper method into your program and call it to turn a number into a leftpadded string of a given exact width. For example, the call System.out.print(padded(7, 5)); prints " 7" (the number 7 with four leading spaces).

Sun Mon Tue Wed Thu Fri Sat 2 3 7 8 9.

Sun Mon Tue Wed Thu Fri Sat 2 3 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

Step by Step Solution

3.32 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Calendars public static void mainString args printMonth31 6 printMonth28 ... 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 Building Java Programs A Back to Basics Approach Questions!