Tags:
tag this topic
create new tag
view all tags
Algorithm hint for second repetition lab (Spring 2024)
banner comment
import's
declare your class
declare the main method
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)
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
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
R
aw View
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2024-01-26
-
CathyBareiss
Home
Site map
Assessment web
BethelAIResources2026 web
CenterForComputing web
ChatGPT web
Intro2AIatBethel web
Main web
Sandbox web
TWiki web
CenterForComputing Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 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