This program is supposed to calculate how much a person would earn over a period of time if his salary was I penny the 1st day, two pennies the 2nd day, 4 pennies the 3rd day, 8 pennies the 4th day and so on.
The program should ask the user for the number of days. Then, it is to display a table showing how much the salary was for each day, and 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.
I was told that I should use a while loop for input validation because it's not supposed to accept a number less than 1 for the number of days worked.
The formula is 2^n-1
Finally, I tried to use a for loop to do the calculation because it's supposed to display a list of totals for each day.
If you could copy and paste and correct this for me, I would greatly appreciate it thanks.
2007-11-09
04:04:05
·
6 answers
·
asked by
USAman
6
in
Programming & Design