I need to create a pseudo code that will prompt for time in 24 hours format, convert it to 12-hour format and also whether it is AM or PM. It will have to repeat until sentinel time of 9999 is entered. Below is what I had come out with, is it correct?
- Prompt for time
- Get time
Enter this loop:
DOWHILE (time != 9999)
IF (time < 0000 OR time > 2400 OR (time%100 >=60))
Display 'Invalid time'
ELSE
IF (time >= 1200 AND time <= 2400 )
format = 'pm' hours = (time/100) - 12 mins = time%100 Display 'The new time is ', hours, '.', mins, format
ELSE format = 'am'
IF (time/100 = 00 ) hours = (time/100) + 12 mins = time%100 Display 'The time is ', hours, '.', mins, format ELSE hours = time/100 mins = time%100 Display ' 'The time is ', hours, '.', mins, format ENDIF
ENDIF
ENDIF
ENDO