Loops 3b

Description

The purpose of this challenge is to use any IF structures (decide between independent IF blocks, IF-ELSE, NESTED IF-ELSE, IF-ELSE-IF) and the DO-WHILE statements while using basic comparison operators.

Requirements

  1. Create a constant int called TARGET, set to 100
  2. Create an integer called total. This will be used as an accumulator.
  3. Create an integer called input
  4. Use a do-while loop that continues as long as total is less than TARGET
  5. Within the do-while, ask the user to enter a value. Use the input variable for the user’s value
  6. Accumulate input in total. Display the value of total (See Sample Interaction) 
  7. Within the do-while, display the following messages as described below
    1. if total is less than 5, show “Long way to go!”
    2. if total is less than 20, show “Keep going!”
    3. if total is less than 50, show “More!”
    4. if total is equal to 50, show “Halfway there!”
    5. if total is less than or equal to 90, show “Go go go!”
    6. if total is greater than 90, show “Home stretch!”
    7. if total is 98 or more, show “Sooo close!” 
  8. After the do-while, show “Success!”

Sample Interaction / Output

Enter a number: 1
We're at 1
Long way to go

Enter a number: 3 
We're at 4
Long way to go 

Enter a number: 14 
We're at 18
Keep going!

Enter a number: 5 
We're at 23
More!

Enter a number: 10 
We're at 33
More!

Enter a number: 10 
We're at 43
More!

Enter a number: 7 
We're at 50
Halfway there!

Enter a number: 11 
We're at 61
Go go go!

Enter a number: 20 
We're at 81
Go go go!

Enter a number: 15 
We're at 96
Home stretch!

Enter a number: 3 
We're at 99
Sooo close!

Enter a number: 9 
We're at 108
Success!

LEGEND
PROGRAM OUTPUT
USER ENTRY
FROM INPUT

CATALOG ID: CPP-LOOP0003b

Print Requirements