Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete C++ program which will produce the sample runs shown at the end

ID: 3624640 • Letter: W

Question

Write a complete C++ program which will produce the sample runs shown at the end of this handout.
The program will ask for the diver’s name. Next, the program asks for how many dives will be entered for this single diver. The number of dives must be 1 to 5. A menu appears asking for the user to choose which dive is being scored. Then, the program asks how many diving scores will be entered. The user must enter a number 3 to 6. Next, the user is prompted to enter the scores, 0 to 10 inclusive. In addition to the statistics, a message must appear indicating whether the diver made the finals or not. To make the finals, the following is how the diver qualifies:
Qualifying for the finals
• For 3 scores - Total must be at least 28.5
• For 4 scores - Total must be at least 39.0
• For 5 scores - Total must be at least 48.0
• For 6 scores - Total must be at least 57.0
After the diver's statistics and qualification are displayed, the user is prompted on whether they want to run the program again. The user must input either Y or N. (See the Sample Runs below).
Dives and Difficulty
• Forward Jump Pike - 1.0
• Forward Dive Straight - 1.6
• Forward 2.5 Tuck - 2.2
• Back 3.5 Tuck - 3.4
• Inward 0.5 Twist Straight - 1.9
All user input is checked and case insensitive. All user input, except for the name, is to be validated. Any invalid entry should produce an appropriate error message and the program repeats a prompt for input.
The design of this program is particularly important. You should spend about 1/3 of your time on this. main() is a driver function and must not have any input/output nor perform any calculations. All the work is done within the functions. Each function has its own pseudo-code. For each function, ask yourself, "What is passed in?", "What is passed back?", "What is returned?"
Be sure that your program demonstrates good design, is well documented, and passes parameters appropriately.
The major purposes of this assignment are to demonstrate:
• good design -- Just because your program produces the correct output does not mean that the program is correct.
• the appropriate use of decision and repetition control structures
• validate user input
Program Requirements and/or Constraints:
• Create your plan BEFORE you begin to write the code.
• Follow the Style Guide.
• Think carefully about the assumptions.
• See the sample output for formatting. Note the alignment of decimals and colons.
• Remember that all rules for functions apply. Use pass-by-value, pass-by-reference, and return.
• You must use at least one boolean returning function.
• State the definition of the function immediately before each function description
• main() is a driver function and thus mostly calls functions to do the work. There must be no input in main().
• Use loops to avoid repeating code.
• User input is case-insensitive.
• Validate each user entry.
• Notice the prompts for dive number and score number, your prompts must increment like this also.
• See the sample runs to determine the correct number of decimal places.
• No global variables are allowed.
• Use comments freely throughout the program.
• Your program must work for any valid input - not just the values shown in the sample output.
• Do not use material beyond the current topic.


One Sample run: User input is represented by [ ]:

Enter the Diver's name: Beach Boys

How many dives will be judged for this diver (1 - 5)? : 2

Menu
ASU Diving Competition - 2011
------------------------------
Dive Difficulty

A. Forward Jump Pike 1.0
B. Forward Dive Straight 1.6
C. Forward 2.5 Tuck 2.2
D. Back 3.5 Tuck 3.4
E. Inward 0.5 Twist Straight 1.9
------------------------------
Enter dive 1 to be judged (A - E): c


How many scores will be entered? (3 - 6) : 4
Enter score 1 : 8
Enter score 2 : 7.5
Enter score 3 : 9
Enter score 4 : 8.2

ASU Diving Competition - 2011
Diving Scores for Beach Boys
------------------------------------------
Dive Difficulty Total Average

Forward 2.5 Tuck 2.20 71.94 8.18

Congratulations, Beach Boys, you qualified for the finals.

Menu
ASU Diving Competition - 2011
------------------------------
Dive Difficulty

A. Forward Jump Pike 1.0
B. Forward Dive Straight 1.6
C. Forward 2.5 Tuck 2.2
D. Back 3.5 Tuck 3.4
E. Inward 0.5 Twist Straight 1.9
------------------------------
Enter dive 2 to be judged (A - E): f

**Error - A, B, C, D, and E*
Enter the dive being scored (A - E): c

How many scores will be entered? (3 - 6) : 2

**Error - number of scores must be 3 to 6*
How many scores will be entered? (3 - 6) : 5
Enter score 1 : 6.8
Enter score 2 : 12

**Error - score must be 0 to 10*
Enter score 2 : 10
Enter score 3 : 8.5
Enter score 4 : 13

**Error - score must be 0 to 10*
Enter score 4 : 8
Enter score 5 : 7.5

ASU Diving Competition - 2011
Diving Scores for Beach Boys
------------------------------------------
Dive Difficulty Total Average

Forward 2.5 Tuck 2.20 89.76 8.16

Congratulations, Beach Boys, you qualified for the finals.

Do you want to run the program again? (Y / N) : n

Press any key to continue . . .

Explanation / Answer

please rate - thanks

sorry I don't understand the scoring, some of the choices have 2 difficulties, so the scores don't have the difficulties included

#include <iostream>
#include <string>
using namespace std;
char getdive(int);
bool repeat();
string getname();
int getnumberdives();
int getscores(double&,double&);
void output(int,double,double,string,int);
int main()
{string name;
char choice;
int dives,numscores,i;
int type;
double total,average;
do
{
name=getname();
dives=getnumberdives();
for(i=0;i<dives;i++)
   {type=getdive(i)-'A';
    numscores=getscores(total,average);
    output(type,total,average,name,numscores);
    }
}while(repeat());
system("pause");
return 0;
}
void output(int type,double total,double average,string name,int d)
{string dives[5]={"Forward Jump Pike 1.0 ",
                  "Forward Dive Straight 1.6 ",
                  "Forward 2.5 Tuck 2.2 ",
                  "Back 3.5 Tuck 3.4 ",
                  "Inward 0.5 Twist Straight 1.9 "};
double threshold[4]={28.5,39,48,57};
cout<<" ASU Diving Competition - 2011 Diving Scores for "<<name
    <<" ------------------------------ ";
cout<<"Dive Difficulty Total Average ";
cout<<dives[type]<<" "<<total<<" "<<average<<endl<<endl;
if(total>=threshold[d-3])
     cout<<"Congratulations, "<<name<<", you qualified for the finals. ";
else
     cout<<"Sorry, "<<name<<", you did not qualify for the finals. ";
}
int getscores(double& total,double& average)
{int i,n;
total=0;
double s;
cout<<"How many scores will be entered? (3 - 6) : ";
cin>>n;
while(n<3||n>6)
    {cout<<"**Error - number of scores must be 3 to 6* ";
     cout<<"How many scores will be entered? (3 - 6) : ";
     cin>>n;
     }
for(i=0;i<n;i++)
    {cout<<"Enter score "<<i+1<<":";
    cin>>s;
    while(s<0||s>10)
        {cout<<"**Error - score must be 0 to 10* ";
         cout<<"Enter score "<<i+1<<": ";
         cin>>s;
         }
     total+=s;
      }
average=total/n;
return n;
}
bool repeat()
{char y;

cout<<"Do you want to run the program again? (Y / N) : ";
cin>>y;
cin.ignore(80,' ');
if(toupper(y)=='Y')
     return true;
return false;
}
int getnumberdives()
{int n;
cout<<"How many dives will be judged for this diver (1 - 5)? : ";
cin>>n;
while(n<1||n>5)
    {cout<<"**Error - number of dives must be 1 to 5* ";
     cout<<"How many dives will be judged for this diver (1 - 5)? : ";
     cin>>n;
     }
return n;
}
string getname()
{string name;
cout<<"Enter the Diver's name: ";
getline(cin,name);
return name;
}
char getdive(int i)
{char choice='F';
    cout<<"Menu ASU Diving Competition - 2011 ------------------------------ ";
while(choice<'A'||choice>'E')
    {cout<<"Dive Difficulty ";
     cout<<"A. Forward Jump Pike 1.0";
     cout<<"B. Forward Dive Straight 1.6 ";
     cout<<"C. Forward 2.5 Tuck 2.2 ";
     cout<<"D. Back 3.5 Tuck 3.4 ";
     cout<<"E. Inward 0.5 Twist Straight 1.9 ";
     cout<<"--------------------------------- ";
     cout<<"Enter dive "<<i+1<<" to be judged(A-E): ";
     cin>>choice;
     choice=toupper(choice);
     if(choice<'A'||choice>'E')
          cout<<"**Error - A, B, C, D, and E* ";
      }
return choice;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote