Starting from:
$30

$24

Lab 5 Problem Solution

Calculate a **running total** of positive integer values using a while loop and a boolean flag that will test for the condition of a **sentinel value**.




- You will use the concept of a running total and sum up a series of inputed values together until the **sentinel value** of (-1) is entered.

- Validate that each inputed value is positive, otherwise have the user re-enter a positive value until valid.

- Once the sentinel value is entered, you will output the `max`, `min`, and `average` with precision up to 2 decimal places (remember not to include the sentinel value (-1) as an inputed value with your calculations).

- You will need to use the **iomanip** library for decimal precision (`setprecision` output modifier).

- You will also need a counter variable to count the number of values inputed.




Example Output




```

Please enter an integer: 1 [entered]

Please enter an integer: 2 [entered]

Please enter an integer: 3 [entered]

Please enter an integer: -1[entered]




Min: 1

Max: 3

Total: 6

Avg: 2.00

```

More products