Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calculate_simple_interest(a, b, c):
- result = a + b + c
- return result
- def calculate_compound_interest(a, b, c):
- result = a - b - c
- return result
- def calculate_loan_payment(a, b, c):
- result = a * b * c
- return result
- def calculate_future_value_of_savings(a, b, c):
- result = a / b / c
- return result
- def goodbye():
- return 'Goodbye'
- def main_menu_options():
- options = [
- 'Main Menu:',
- ' 1.Calculate Simple Interest',
- ' 2.Calculate Compound Interest',
- ' 3.Calculate Loan Payment',
- ' 4.Calculate Future Value of Savings',
- ' 5.Quit'
- ]
- return '\n'.join(options)
- def main_menu(customer_input):
- possible_options = {
- '1': lambda a, b, c: a + b + c,
- # '1': calculate_simple_interest,
- '2': calculate_compound_interest,
- '3': calculate_loan_payment,
- '4': calculate_future_value_of_savings,
- '5': goodbye,
- }
- while True:
- if customer_input not in possible_options:
- print('Value is incorrect. Enter new value.')
- else:
- if customer_input == '5':
- print(goodbye())
- break
- value_1 = float(input())
- value_2 = float(input())
- value_3 = float(input())
- calculation_result = possible_options[customer_input](value_1, value_2, value_3)
- print(f"{calculation_result:.2f}")
- customer_input = input('Do you want to perform another calculation? (yes/no): ')
- possible_chooses = ['yes', 'no']
- while True:
- if customer_input not in possible_chooses:
- print('Enter correct value! (yes/no) ')
- customer_input = input()
- else:
- break
- if customer_input == 'no':
- print(goodbye())
- break
- else:
- print(main_menu_options())
- customer_input = input()
- print(main_menu_options())
- customer_choose = input()
- main_menu(customer_choose)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement