English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a program that calculates how much a person would earn over a period
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 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 number of pennies.

2006-09-24 13:03:02 · 5 answers · asked by Emily 1 in Computers & Internet Programming & Design

5 answers

Use cin to get the input from the user about the amount of days.
If the amount of days is 0 or less, the answer is 0.
If the amount of days is 1 or more, initialise a variable total to 1 or 0.01
Make another variable daily_amount also equal to 1 or 0.01
For every day after the first, make this a loop
double the daily_amount, x *= 2 or x = x * 2
make the total equal to total plus daily_amount
end the loop when the number of days is complete.
The 'total' should be your answer. You may have to divide this by 100.

2006-09-28 04:45:38 · answer #1 · answered by Mark aka jack573 7 · 0 0

There's many great examples of C++ on the internet. I think you should learn it instead of trying to get other people to do your work for you. You'll actually be better off in the long run. Good Luck!

2006-09-24 20:12:17 · answer #2 · answered by Anonymous · 0 0

It sounds so simple that I wont waste 5 minutes of my time doing your homework for you.
Heres a hint, do you know binary? Do you know how to divide by 100? Then your done.

2006-09-25 09:08:41 · answer #3 · answered by justme 7 · 0 0

This is simple but boring Programming 101 stuff; you should do it yourself.

2006-09-24 21:26:03 · answer #4 · answered by Andy T 7 · 0 0

go to any leading bookshops, get the book titled, C++ For DUMMIES.... This might solve your problem....

2006-09-24 20:25:38 · answer #5 · answered by Khairudin Bin Salim 4 · 0 0

fedest.com, questions and answers