Urgent Help with C++ Pseudocode Assignment

Hi. I need urgent help with an assignment. I have tried getting help from tutors at my school, but none are available at the moment. I'm supposed to write the pseudocode for a calendar program that asks the user for a month and year and then displays the calendar for that month. First, I had to find the number of days in the month and compute the offset to know what day of the week the month starts on, and I did that without trouble, but I'm now supposed to use that information to display a table, showing the calendar, with the month starting at the right day of the week, and I have no idea how to do this. I think I would use a loop for at least part of it, but that's about all I know. So far, I have:
getMonth()
PROMPT for month
RETURN month

getYear()
PROMPT for year
RETURN year

isLeapYear(year)
IF ()(year MOD 4 = 0) and (year MOD 400 NOT = 0()
RETURN true
ELSE
RETURN false

numDaysInYear(year)
IF isLeapYear(year))
RETURN 366
ELSE
RETURN 365

numDaysInMonth(year, month)
IF (month = 1 OR month = 3 OR month = 5 OR month = 7 OR month = 8 OR
month = 10 OR month = 12)
RETURN 31
ELSE IF (month = 2)
RETURN 28 + isLeapYear(year)
ELSE IF (month = 4 OR month = 6 OR month = 9 OR month = 11)
RETURN 30

computeOffset(year, month)
FOR (startMonth = 1 to startMonth < month, increment startMonth)
SET numDays += numDaysInMonth(startMonth)
FOR (startYear = 1753 to startYear < year)
SET numDays += numDaysInYear(startYear)
SET offset = numDays MOD 7
RETURN offset

displayTable(offset, numDaysInMonth)

I'm totally stuck on the display function. Can you please help as soon as possible? Thanks.
think about what you need to do..

first, you need the table, which here probably has a header column: mon tues wed thurs fri sat sun ... you need to print those, probably using tabs if doing a console program, but they need to align.

Then you need to use what you found, the starting point, and backtrack. That is, say it starts on wd. Then you skip mon (write whitespace, tabs or spaces) and tues and then write 1 in wd, 2 in thrusday... until you hit the last day of your month (varies based on which month and leapyear). When you finish with the last day of the week (which I did not do right, most go sun to sat) write an end of line.

It would be a loop, yes. Loop over 7X5 is 35, 5 rows, is one way to do it, where some of the 35 are blanks (on the front and back end). Or you can loop over 35, and exit early rather than write empty space at the finish.

Topic archived. No new replies allowed.