Question
Python programming Write a program that calculates the amount of money a person would earn over a period of time if his or her salary
Python programming
Write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies.
Alter the program so that pennies, nickels, dimes and quarters may be chosen by the user along with the what the pay for each day would be.
I have written the code but cant seem to get any other coin beside pennies to work. Please help.
coin_type = input('Enter coin type (Pennies, Nickels, Dimes, or Quarters): ') days = int(input('Enter the number of days: ')) earnings = 0 pay = 0 if coin_type == 'pennies' or coin_type == 'Pennies': pennies = 0.01 pennies += earnings elif coin_type == 'nickels' or coin_type == 'Nickels': nickels = 0.05 nickels += earnings elif coin_type == 'dimes' or coin_type == 'Dimes': dimes = 0.10 dimes += earnings elif coin_type == 'quarters' or coin_type == 'Quarters': quarters = .25 quarters += earnings earnings += pay for i in range(days): pay *= 2 print('{}\t${:.2f}'.format(i + 1, pay)) print('Day\tEarnings ({})'.format(coin_type)) print('---------') print(' Total earnings: ${:.2f}'(pay))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started