In: Computer Science
PSEUDOCODE:
1. You are designing software for a voting booth. Please create pseudocode for a modular program that:
- Takes in a user inputted integer for age. If their age is below 18, display "you are too young to vote"
- Only If their age is high enough, please ask them which candidate they wish to vote for. Valid options are "dog", "cat", "horse"
- If they did not choose a valid option display "you did not choose a valid option"
- If they were old enough and chose a valid option display
"You voted for <name>" where name represents the candidate
they chose
You may create modules / functions as you please but there must be at least 2 modules or functions and they must be meaningful. You can not just group arbitrary statements to gether.
Make sure to test our your solution on your own by plugging values in before submitting the pseudocode for the program.
2. Define a function in pseudocode named 'passwordChecker'that has one String parameter named password and returns True if the password was 'batman' or 'robin' and False if the password was anything else. You do not need to display anything or create any modules. Just simply a function definition.
1)
Pseudocode : Voting booth
BEGIN
NUMBER age
STRING vote
INPUT age
IF agechecker(age) THEN
INPUT vote
display(vote)
END IF
END
MODULE agechecker(age)
BEGIN
IF age>=18 THEN
Print “Please Select a valid option”
return true
ELSE
Print “You are too young to vote”
return false
END IF
END
MODULE display(vote)
BEGIN
IF vote==”dog” OR vote==”cat” OR vote==”horse”
Print “You voted for”, vote
ELSE
Print "you did not choose a valid option"
END IF
END
2) Since only the function defintion is asked and it is really not clear if 1 and 2 are seperate I will assume that both are seperate
passwordchecker(pass)
BEGIN
IF pass=="batman" or pass=="robin"
return True
ELSE
return False
END IF
END