Problem

Write a program that produces calendars as output. Your program should have a method that...

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.

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 left-padded 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).

// Returns a string of the number n, left-padded// with spaces until it is at least the given width.public static String padded(int n, int width) {	String s = "" + n;	for (int i = s.length(); i < width; i++) {		s = " " + s;	}	return s;}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 3
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT