Birthday Money
Amanda has received 6 birthday cards for her birthday. Each birthday card contained money from her friends and relatives.
Write a program that allows Amanda to enter how much money each card contained. The program should repeat 6 times, each time allowing Amanda to enter how much was in each card in whole pounds. This should then be added to a total. The total should then be displayed to Amanda.
Enter the amount in card £5 Enter the amount in card £10 Enter the amount in card £15 Enter the amount in card £10 Enter the amount in card £20 Enter the amount in card £10 The total amount of money received is £ 70 HAPPY BIRTHDAY!
SET total TO 0
FOR counter FROM 1 TO 6 DO
RECEIVE money FROM KEYBOARD
SET total TO total + money
END FOR
OUTPUT "The total amount of money received is £", total
OUTPUT "HAPPY BIRTHDAY!"
total = 0
for i in range(6):
money = int(input("Enter the amount in card £"))
total = total + money
print("The total amount of money received is £", total)
print("HAPPY BIRTHDAY!")
# Total is set to 0
total = 0
# Repeat 6 times
for i in range(6):
# Ask how much was in each card
money = int(input("Enter the amount in card £"))
# Add the value of each card to the total
total = total + money
# Display the total
print("The total amount of money received is £", total)
print("HAPPY BIRTHDAY!")
Extension
Extend the program to let a user enter how many cards they received, and then loop based on their response.
How many cards did you receive? 3 Enter the amount in card £20 Enter the amount in card £10 Enter the amount in card £15 The total amount of money received is £ 45 HAPPY BIRTHDAY!