Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+14 votes

For the main method what type of loop structure do we have to use in the main method to make the program prompt the user to enter another year or if they are done enetering years?

asked in CSC211_Winter2018 by (1 point)

2 Answers

+9 votes
 
Best answer

You will need to use a sentinel loop to prompt user input until they have typed all of their values in. At which point, the loop will end due to the user input of the sentinel.

answered by (1 point)
selected by
+8 votes

Use the sentinel loop structure. Prompt the user and read the answer before the loop. While the answer isn't "no", put all of the code about entering the year and determining if it a leap year or not. Then at the bottom of the loop, prompt the user asking if the user wants to enter another year and read the answer.

answered by (1 point)
...