- Part One, Two, Three: If, Elsif, Else
- Optional One: Loop
- Optional Two: List
We can make decisions in our code by using If, Elsif, Else blocks.
- A user's initial balance is 0.0.
- Display the user's balance.
- Ask the user what they would like to do.
- If they type "balance", display their balance.
- If the user types anything other than "balance", display the message "Invalid selection!".
- Add "deposit" as a program option.
- If the user types "deposit", ask the user for the deposit amount and then add this to the user's current balance.
- Add "withdraw" as a program option.
- If the user types "withdraw", ask the user for the withdrawal amount and then deduct this from the user's current balance.
- Note: The user should not be allowed to withdraw more than their current balance!
- Enclose the program statements in a loop to allow the program to repeat until the user chooses to exit the program.
- Store the value of each transaction in a list.
- Add "view history" as a program option.
- If this option is selected, display each transaction.
Author | Rachael Colley; Updated for Python by James H. |
---|---|
Keywords | If, Elsif, Else, List, Loop, Number, Addition |