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

Write a unit test case functions for every function you define. These test cases

ID: 3567897 • Letter: W

Question

Write   a   unit   test   case   functions   for   every   function  
you   define.   These   test   cases   should   be   called   in   the   main   function.       After   you  
are   done   testing,   comment   these functions out   so   that   your   output   adheres   to  
the   requirement   and   does   not   show   additional   content

#include

#include

#include

using namespace std;

void Result(float scores[], int judges, int diveType, float difficulty, string name);

void Menu();

void Dive();

int main()

{

   Dive();

   system("Pause");

   return 0;

}

//prints menu for the user

void Menu()

{

   cout << " Menu" << endl;

   cout << " ASU Diving Competition" << endl;

   cout << "-------------------------------------------------------" << endl;

   cout << " Dive Difficulty" << endl;

   cout << " 1. Forward Jump Pike 1.0" << endl;

   cout << " 2. Forward Dive Straight 1.6" << endl;

   cout << " 3. Forward 2.5 Tuck 2.2" << endl;

   cout << " 4. Back 3.5 Tuck 3.4" << endl;

   cout << " 5. Inward 0.5 Twist Straight 1.9" << endl;

   cout << "-------------------------------------------------------" << endl;

}

void Dive()

{

   string name;

   float difficulty = 0;

   float scores[6];

   int d, s, j;

   int diveCount;

   int diveType;

   int judges;

   int rProgram = 1;

   char again;

   while (rProgram == 1)

   {

       //get diver name

       cout << "Please enter the Diver's name ";

       cin >> name;

       //get # of dives

       cout << "How many dives will be judged? (1-5) ";

       cin >> diveCount;

       while (diveCount < 1 || diveCount > 5)

       {

           cout << " Please enter a valid number. (1-5) ";

           cin >> diveCount;

       }

       //loop for all dives

       for (d = 1; d <= diveCount; d++)

       {

           //display menu and set dive difficulty

           Menu();

           cout << "Please enter dive " << d << " to be judged. (1-5)" << endl;

           cin >> diveType;

           while (difficulty == 0)

           {

               switch (diveType)

               {

               case 1: difficulty = 1.0;

                   break;

               case 2: difficulty = 1.6;

                   break;

               case 3: difficulty = 2.2;

                   break;

               case 4: difficulty = 3.4;

                   break;

               case 5: difficulty = 1.9;

                   break;

               default: cout << "Please enter a valid dive number. (1-5)" << endl;

                   cin >> diveType;

               }

           }

           //get number of judges (number of scores to be entered)

           cout << "How many judges will be scoring the dive? (3-6)" << endl;

           cin >> judges;

           while (judges < 3 || judges > 6)

           {

               cout << "Please enter a valid number of judges. (3-6)" << endl;

               cin >> judges;

           }

           //get scores

           j = 1;

           for (s = 0; s < judges; s++)

           {

               while (j <= judges)

               {

                   cout << "Please enter the score from judge #" << j << ". (0-10)" << endl;

                   cin >> scores[s];

                   j++;

                   while (scores[s] < 0 || scores[s] > 10)

                   {

                       cout << "Please enter a valid score. (0-10)" << endl;

                       cin >> scores[s];

                   }

               }

           }

           //call function results

           Result(scores, judges, diveType, difficulty, name);

           difficulty = 0;

       }

       //run the program again?

       cout << "Would you like to run the program again? (y/n)" << endl;

       cin >> again;

       if (again == 'n' || again == 'N')

       {

           rProgram = 0;

       }

   }

}

//function to print out dive name

void Divename(int diveType)

{

   switch (diveType)

   {

   case 1: cout << "Forward Jump Pike";

       break;

   case 2: cout << "Forward Dive Straight";

       break;

   case 3: cout << "Forward 2.5 Tuck";

       break;

   case 4: cout << "Back 3.5 Tuck";

       break;

   case 5: cout << "Inward 0.5 Twist Straight";

       break;

   }

}

//function to print statistics

void Result(float scores[], int judges, int diveType, float difficulty, string name)

{

   float average;

   float total;

   float sum = 0;

   int t;

   cout << " ASU Diving Competition 2014" << endl;

   cout << " Diving Scores for " << name << endl;

   cout << " --------------------------------------------------------------------------------" << endl;

   cout << " Dive Difficulty Total Average" << endl;

   Divename(diveType);

   for (t = 0; t < judges; t++)

   {

       sum += scores[t];

       total = sum *difficulty;

       average = sum / judges;

   }

   cout << fixed<<" " << difficulty << " " << total << " " << average << endl << endl;

   //Finals results

   if (judges == 3 && total >= 28.5)

       cout << "Congratulations " << name << "! You qualified for the Finals!" << endl;

   else if (judges == 4 && total >= 39)

       cout << "Congratulations " << name << "! You qualified for the Finals!" << endl;

   else if (judges == 5 && total >= 48)

       cout << "Congratulations " << name << "! You qualified for the Finals!" << endl;

   else if (judges == 6 && total >= 57)

       cout << "Congratulations " << name << "! You qualified for the Finals!" << endl;

Explanation / Answer

http://www.writingcentre.us/ saves your time

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