Declare number as integer
Declare response as character
Repeat
Set hour = 0 Write “This program can calculate your total hours worked” Write “Enter the number of hours worked on Monday:” Write “Enter 0 when you are done” Input number While number != 0 Set hours = hours + number Write “Enter your hours for the next day or 0 if you are done:” Input number End While Write “Your total hours worked are” + hours Write “Add more hours? (Y or N)” Input response
Until response == “N”
1. A while loop will not execute the body of the code if you have your test condition incorrect.
2. If the test data is true then the body runs once: Declare …show more content…
(Y or N)” Input response
Until response == “N”
1. A while loop will not execute the body of the code if you have your test condition incorrect.
2. If the test data is true then the body runs once: Declare hours As Integer Set hours = 39 While hours < 39 Write hours Set hours = hours + 1
The code can run only once, because the body can be true once.
3. If you begin your loop with “While True” it will not terminate.
Declare hours as integer
Declare number as integer
Declare response as character
Repeat
Set hour = 0 Write “This program can calculate your total hours worked” Write “Enter the number of hours worked on Monday:” Write “Enter 0 when you are done” Input number While number != 0 Set hours = hours + number Write “Enter your hours for the next day or 0 if you are done:” Input number End While Write “Your total hours worked are” +