Loops 13

Description

The purpose of this challenge is to use NESTED loops and Input Validation. This challenge implements scoring for a Reining event.

Reining scoring

Riders put their horses through patterns made up of maneuvers. Judges will score the riders based on each maneuver. The rider’s score starts at a 70.

Valid scoring ranges from:
  -1.5 : extremely poor
  -1   : very poor
  -0.5 : poor
  0    : correct 
  +0.5 : good
  +1   : very good
  +1.5 : excellent

The judge will give the rider one of these scores for each maneuver in the pattern. At the end of the pattern, the judge will add or subtract each maneuver score to/from the initial score of 70.

Multiple judges can score an event. Then, the final scores of each judge will be added together to result in the rider’s composite score for their pattern

Requirements

  1. Declare a const double START_SCORE initialized to 70
  2. Declare a const int MANEUVERS initialized to 4
  3. Declare an int adjusted_score
  4. Declare two doubles judge1, judge2. Initialize these variables to START_SCORE
  5. Declare three doubles: maneuver_score1, maneuver_score2, composite_score
  6. Write a loop that will repeat starting from 1 up to MANEUVERS (the constant). You can use any looping syntax, but remember that one particular looping construct is especially suited for this task.
  7. The loop you wrote in Step 6 will act as an outer loop. Within this loop,
    1. Ask the user to enter the score of a maneuver as determined by Judge 1…”How would Judge 1 score maneuver x?”. Receive the user’s input into maneuver_score1.
    2. When asking the user for the maneuver score, use an input-validation loop. The only allowed values for the score are -1.5, -1, -0.5, 0, 0.5, 1, 1.5. ALTERNATE  APPROACH (OPTIONAL) – If you take the maneuver score and multiply it by 10, you can store this new value in adjusted_score.  This effectively takes the score, which is a numeric value and converts it into an integer value. It will then be possible to use divisibility to simply the range checking.
    3. Display a message if the user enters a judge’s score that is not in the allowed range. The following should give you an idea of how to write the score input with input validation
      do
      {
        // ask the user to enter score for Judge 1
        cout << "How would Judge 1 score this maneuver? "; 
        cin >> maneuver_score1;
      
        if (/* maneuver_score1 is not valid */)
          cout << "## Enter a valid score ##" << endl;
      
      } while (/* expression used for input validation */);
      
    4. Repeat the above 3 steps to ask for Judge 2’s score in a similar manner. Make sure to use maneuver_score2 for this input value.
    5. Accumulate maneuver_score1 into judge1, and maneuver_score2 into judge2 respectively. Basically, the maneuver score will be added or subtracted into each judge’s running total.
    6. Display each judge’s accumulated score so far. See Sample Interaction.
  8. Calculate the final composite_score as the sum of all the judges’ scores.
  9. Display the final rider’s score. See Sample Interaction.

Sample Interaction / Output

How would Judge 1 score maneuver 1? 0
How would Judge 2 score maneuver 1? 0.5

Judge 1 current score: 70
Judge 2 current score: 70.5

How would Judge 1 score maneuver 2? 1
How would Judge 2 score maneuver 2? -1

Judge 1 current score: 71
Judge 2 current score: 69.5

How would Judge 1 score maneuver 3? -2
## Enter a valid score ##

How would Judge 1 score maneuver 3? 2
## Enter a valid score ##

How would Judge 1 score maneuver 3? -1.1
## Enter a valid score ##

How would Judge 1 score maneuver 3? -0.3
## Enter a valid score ##

How would Judge 1 score maneuver 3? 1.9
## Enter a valid score ##

How would Judge 1 score maneuver 3? 0.5
How would Judge 2 score maneuver 3? 0.5

Judge 1 current score: 71.5
Judge 2 current score: 70

How would Judge 1 score maneuver 4? 0.5
How would Judge 2 score maneuver 4? 0.5

Judge 1 current score: 72
Judge 2 current score: 70.5

Judge 1 Final score: 72
Judge 2 Final score: 70.5

Rider's composite score: 142.5

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-LOOP00013 – Contributed by Erica M. 

Print Requirements