Design a program in pseudocode that calculates the amount of money a person would earn over a period of time if their salary is one penny the first day, and then doubles each day. The program should ask the user for the number of days. Display what the salary was for each day, and then show the total pay for the end of the period. The output should be displayed in dollar amount, not number of pennies.
I have the code but i do not know if it works PLEASE HELP!!!!!:
Declare Integer days, counter = 1, penny = 1, total = 0
Declare Real salary, totalPay
Display "Enter a number of days."
Input days
Display "Days",TAB,"Salary"
While counter<= days
Set salary = penny/100
Set total = penny
Display counter, TAB, salary
Set penny = penny * 2
Set counter = counter + 1
End While
Set totalPay = total * 100
Display "The total payment of your time working here will be $", totalPay
2 answers
I am not sure abut the rest, but how you have it set up to display pennies as a dollar amount isn't going to work. For an example, if you end up with 100 pennies at the end, and you multiply that by 100, you will get 10,000, not $1.00. It would be easier if you set penny=.01 (not sure what variable type it would be, it's been a while) and not even mess with changing it into a dollar amount. Just display totalPay as the final amount of penny. The decimal will take care of the conversion itself.
I see that the line that says
Set total = penny
should have the penny value dividing by 100 like the line
Set salary = penny/100
I see that error but other than that is there anything else wrong like a variable placement or variable value wrong?
Set total = penny
should have the penny value dividing by 100 like the line
Set salary = penny/100
I see that error but other than that is there anything else wrong like a variable placement or variable value wrong?