Loops 7a

Description

The purpose of this challenge is to use DO-WHILE and FOR loop. This challenge uses the concepts of accumulators and loops.

Requirements

  1. Assume you were offered a job that paid $0.01 on the first day, $0.02 the 2nd day, $0.04 the 3rd day (each day’s income is double the previous day’s income). This program will calculate how much you made given a certain number of days worked.
  2. Ask the user to enter a value that represents how many days will be worked. Use a DO-WHILE to implement input validation to only allow the user to enter a value between 5 and 30. You can display a message accordingly if the user’s input is out of this range (See Sample Interaction).
  3. Given the number of days provided by the user, display what you will make on each day
  4. Calculate and show how much you made for the entire work period (the number of days entered on Step 2)
  5. You should #include <iomanip> and add the following to display decimal numbers neatly
    cout << fixed << setprecision(2);
    

DO NOT USE

Any power or exponentiation formulas

Sample Interaction / Output

How many days will you work? 35
35 is invalid input
How many days will you work? -15
-15 is invalid input
How many days will you work? 5
On day 1, you will make $0.01
On day 2, you will make $0.02
On day 3, you will make $0.04
On day 4, you will make $0.08
On day 5, you will make $0.16
After 5 days, you will have made $0.31
How many days will you work? 30

On day 1, you will make $0.01
On day 2, you will make $0.02
On day 3, you will make $0.04

...
(show all days here)
...
On day 29, you will make $2684354.56
On day 30, you will make $5368709.12
After 30 days, you will have made $10737418.23

Pay close attention to the last line above that shows the total amount earned having worked 30 days (this is the total amount earned through the 30 days).

Make sure your total shows the amount above, not a penny more, not a penny less.

If you use a method that arrives at $10737418.24 total earnings, do not simply subtract a penny to make it correct. HINT: If you arrive at a number with 24 cents, you are not showing the accumulated earnings for the 30 day period, you are displaying the amount that would be earned on the 31st day

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-LOOP0007a

Print Requirements