Voting Age Checker – Flowchart

For this challenge you are going to code a script to ask a user how old they are and inform them as to whether they are old enough to vote or not. If they are not old enough to vote, the script will calculate how many years the user will have to wait before being allowed to vote.

Flowchart


flowchart-voting-age-checker

Task #1


Recreate this flowchart by writing the pseudo-code of this algorithm using code2flow.com.

Task #2


Implement this code using our online Python IDE:

Task #3


Test your code. Is it behaving the way you would expect? What input data could you use to test your code?

Test # Input Values Expected Output Actual Output
#1 Age: 21 You can vote
#2 Age: 16 You will be able to vote in 2 years.
#3 Age: 100 You can vote.
#4 Age: 0 You will be able to vote in 18 years.
#5 Age: 18 You can vote
#6 Age: (leave blank) Error Message
#7 Age: “I am fifteen years old” Error Message

Task #4: Improve your code


How could you improve your code to fix some of the errors you have spotted by completing your test plan? What validation routines could you add to this code to make it more robust?
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3.2 / 5. Vote count: 21

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,