The Student Room Group

computer science

If Monday = 0, Tuesday = 1 etc…

Write an algorithm which:
Asks the user to enter a number,
Outputs the day that the number represents,
Validates the number so that an error message displays if the number is not a valid weekday number.
Reply 1
Original post by aharsley6
If Monday = 0, Tuesday = 1 etc…

Write an algorithm which:
Asks the user to enter a number,
Outputs the day that the number represents,
Validates the number so that an error message displays if the number is not a valid weekday number.


What programming language is this in/is it in pseudocode or a flowchart? You'd be looking at getting a user input, assigning to a variable (e.g. user_Input = INPUT()') and then either using several if, else-if statements to go if user_input = whatever, then output the day. You can then have an else statetement that outputs invalid if the number doesn't match. If you're programming, you could also have a dictionary with "0" assigned to "Monday", etc. and then getting that location. Hopefully that makes sense, you can piece it together from there. Best of luck

Quick Reply

Latest

Trending

Trending