Difference: CSC121F2023Lab04Hint1 (1 vs. 2)

Revision 22023-09-08 - CathyBareiss

Line: 1 to 1
 
META TOPICPARENT name="CSC121F2023Lab04"

Algorithm hint for second repetition lab (Fall 2023)

  • banner comment
  • import's
  • declare your class
  • declare the main method
Changed:
<
<
    • declare your variables. You will at least need something for the number inputted, something for the result, and something for the operation
>
>
    • declare your variables. You will need at least three (see the input statement below)
 
    • ready your keyboard
    • get the three inputs for the user (year, month, starting day)
    • determine the number of days in the month (set a variable)

Revision 12023-06-19 - cathybareiss

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="CSC121F2023Lab04"

Algorithm hint for second repetition lab (Fall 2023)

  • banner comment
  • import's
  • declare your class
  • declare the main method
    • declare your variables. You will at least need something for the number inputted, something for the result, and something for the operation
    • ready your keyboard
    • get the three inputs for the user (year, month, starting day)
    • determine the number of days in the month (set a variable)
      • A use of switch statement can be nice esp. if you don't always use the break (until done listing all that have 30 days, etc)
      • Be very careful and test fully about leap years
    • display the name of the month (a simple selection statement)
    • Use a for loop to display spaces for the "missing start days". The output should be a print not a println
    • Set a counter (that counts how many days of a week have been printed) to the start day (since you have just printed those "blanks")
    • Use a loop (a for loop would be nice) to count the days (1 to 28, 29, 30, or 31) based on the number of days in the month
      • print the current day
      • add one to the counter of the days of the week
      • if you have just printed Saturday,
        • set the counter back to zero
        • print a new line
    • make sure you finish the end of the month nicely
    • finish the main method
  • finish the class
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback