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

The following code has two errors when run in Visual Studio as a cpp file. I wou

ID: 3567771 • Letter: T

Question

The following code has two errors when run in Visual Studio as a cpp file. I would love it if someone would assist me in adjusting the code so that it will run in visual studio.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void printResult(int Score[], int scoresCount, float difficulty, string name);
void printMenu();
void getDiveResult();

int main()
{
   getDiveResult();
}
void getDiveResult()
{
   string name;
   int i, j, k, l;
   int scoresCount;
   int Score[6];
   char ch;
   int count;
   float difficulty = 0;
   bool flag = true;
   while (flag)
   {
       cout << " Enter the Diver's name:";
       cin >> name;
       while (true)
       {
           cout << "how many dives will be judged for this diver";
           cin >> count;
           if (count >= 1 && count <= 5)
               break;
           else
               cout << "Error. Enter the correct value(1-5)";
       }
       for (j = 0; j        {
           printMenu();
           cout << " Enter dive" << j << "to be judged (A-E)";
           cin >> ch;
           while (true){
               switch (ch)
               {
               case 'a': difficulty = 1.0; break;
               case 'b': difficulty = 1.6; break;
               case 'c': difficulty = 2.2; break;
               case 'd': difficulty = 3.4; break;
               case 'e': difficulty = 3.9; break;
               default: cout << " Error. Enter the correct value (a-e):"; break;
               }
               if (difficulty != 0)
                   break;
           }
           while (true)
           {
               cout << " How many Scores will be Entered? (3-6):";
               cin >> scoresCount;
               if (scoresCount >= 3 && scoresCount <= 6)
                   break;
               else
                   cout << "Error. Enter the correct value(3-6)";
           }
           i = 0;
           while (i            {
               while (true)
               {
                   cout << " Enter the Score" << i;
                   cin >> Score[i];
                   if (Score[i] >= 0 && Score[i] <= 10)
                       break;
                   else
                       cout << "Error. Enter the correct value(1-10)";
               }
               i++;
           }
           printResult(Score, scoresCount, difficulty, name);
       }
       cout << " Do you want to run the program Again (y-yes;n-no)";
       cin >> ch;
       if (ch == 'n')
           flag = false;
   }
}
void printResult(char ch, int Score[], int scoresCount, double difficulty, string name)
{
   double total, avg;
   int sum = 0;
   char*divename = getDive(ch);
   cout << "Asu- Diving Competition -2011 ";
   cout << "Diving Scores for " << name << endl;
   cout << "----------------------------------------- ";
   cout << " Dive Difficulty Total Average";
   cout << " " << divename << " ";
   for (int i = 0; i    {
       sum += Score[i];
       total = sum * difficulty;
       avg = (double)sum / scoresCount;
   }
   cout << difficulty << " " << total << " " << avg;

   //calls the method printResult to print dives results status
   printResult(name, scoresCount, total);
}
//Prints the result of diver
void printResult(string name, int scorsCount, double total)
{
   if (scorsCount == 3 && total >= 28.5)
       cout << " Congratulations !" << name << ".You are qualified" << endl;
   else if (scorsCount == 4 && total >= 39)
       cout << " Congratulations !" << name << ".You are qualified" << endl;
   else if (scorsCount == 5 && total >= 48)
       cout << " Congratulations !" << name << ".You are qualified" << endl;
   else if (scorsCount == 6 && total >= 57)
       cout << " Congratulations !" << name << ".You are qualified" << endl;
}

//Prints the menu for diver
void printMenu()
{
   cout << " Menu ";
   cout << "Asu- Diving Competition -2011 ";
   cout << "----------------------------------------- ";
   cout << "Drive 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 << "----------------------------------------- ";
}
//The method getDive returns the type of diving
char * getDive(char ch)
{
   const char *divename;
   switch (ch)
   {
   case 'a':
       divename = "Forward Jump Pike";
       break;
   case 'b':
       divename = "Forward Dive Straight";
       break;
   case 'c':
       divename = "c.Forward 2.5 Tuck";
       break;
   case 'd':divename = "Back 3.5 Tuck ";
       break;
   case 'e':divename = "e.Inward 0.5 Twist Straight ";
       break;
   }
   return 0;
}

Explanation / Answer

#include<iostream>

using namespace std;
void result(string,int,double);
void printResult(char,int[], int , double ,string);
void printMenu();
void getDiveResult();
char* getDive(char);
int main()
{
getDiveResult();
}
void getDiveResult()
{
string name;
int i, j, k, l;
int scoresCount;
int Score[6];
char ch;
int count;
float difficulty = 0;
bool flag = true;
while (flag)
{
cout << " Enter the Diver's name:";
cin >> name;
while (true)
{
cout << "how many dives will be judged for this diver";
cin >> count;
if (count >= 1 && count <= 5)
break;
else
cout << "Error. Enter the correct value(1-5)";
}
for (j = 0; j<count;j++)
   {
printMenu();
cout << " Enter dive" << j << "to be judged (A-E)";
cin >> ch;
while (true){
switch (ch)
{
case 'a': difficulty = 1.0; break;
case 'b': difficulty = 1.6; break;
case 'c': difficulty = 2.2; break;
case 'd': difficulty = 3.4; break;
case 'e': difficulty = 3.9; break;
default: cout << " Error. Enter the correct value (a-e):"; break;
}
if (difficulty != 0)
break;
}
while (true)
{
cout << " How many Scores will be Entered? (3-6):";
cin >> scoresCount;
if (scoresCount >= 3 && scoresCount <= 6)
break;
else
cout << "Error. Enter the correct value(3-6)";
}
while (i<scoresCount)
       {
while (true)
{
cout << " Enter the Score" << i;
cin >> Score[i];
if (Score[i] >= 0 && Score[i] <= 10)
break;
else
cout << "Error. Enter the correct value(1-10)";
}
i++;
}
printResult(ch,Score, scoresCount, difficulty, name);
}
cout << " Do you want to run the program Again (y-yes;n-no)";
cin >> ch;
if (ch == 'n')
flag = false;
}
}
void printResult(char ch,int Score[], int scoresCount, double difficulty, string name)
{
double total, avg;
int sum = 0;
char *divename = getDive(ch);
cout << "Asu- Diving Competition -2011 ";
cout << "Diving Scores for " << name << endl;
cout << "----------------------------------------- ";
cout << " Dive Difficulty Total Average";
cout << " " << divename << " ";
for (int i = 0; i<scoresCount;i++)
sum += Score[i];
total = sum * difficulty;
avg = (double)sum / scoresCount;

cout << difficulty << " " << total << " " << avg;

//calls the method printResult to print dives results status
result(name, scoresCount, total);
}
//Prints the result of diver
void result(string name, int scorsCount, double total)
{
if (scorsCount == 3 && total >= 28.5)
cout << " Congratulations !" << name << ".You are qualified" << endl;
else if (scorsCount == 4 && total >= 39)
cout << " Congratulations !" << name << ".You are qualified" << endl;
else if (scorsCount == 5 && total >= 48)
cout << " Congratulations !" << name << ".You are qualified" << endl;
else if (scorsCount == 6 && total >= 57)
cout << " Congratulations !" << name << ".You are qualified" << endl;
}

//Prints the menu for diver
void printMenu()
{
cout << " Menu ";
cout << "Asu- Diving Competition -2011 ";
cout << "----------------------------------------- ";
cout << "Drive 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 << "----------------------------------------- ";
}
//The method getDive returns the type of diving
char * getDive(char ch)
{
const char *divename;
switch (ch)
{
case 'a':
divename = "Forward Jump Pike";
break;
case 'b':
divename = "Forward Dive Straight";
break;
case 'c':
divename = "c.Forward 2.5 Tuck";
break;
case 'd':divename = "Back 3.5 Tuck ";
break;
case 'e':divename = "e.Inward 0.5 Twist Straight ";
break;
}
return 0;
}

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