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

Programming assignment (20 points) 0. 1 point for having the program description

ID: 3566826 • Letter: P

Question

Programming   assignment   (20   points)
0. 1   point   for   having   the   program   description   in   place.
1. COLLEGE Diving   Scores
Write   a   complete   C++   program,   which   will   produce   the   sample  
runs   shown   at   the   end   of   this   document.

The   program   will   ask   for   the   divers   name.   Next,   the   program   asks  
for   how   many   dives   will   be   entered   for   this   single   diver.   The  
number   of   dives   must   be   in   between   1   to   5.   A   menu   appears  
asking   for   the   user   to   choose   which   dive   is   being   scored.   Then,   the  
program   asks   for   the   number   of   diving   scores   that   will   be   entered
(from   different   judges).       The   user   must   enter   a   number   between   3  
and   6.   Next,   the   user   is   prompted   to   enter   these   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

Explanation / Answer

// CHAMCHA.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
void printResult(int Score[],int scoresCount,float difficulty,string name);
void printMenu();
void getDriveResult();


int main()
{
getDriveResult();
}

void getDriveResult()
{
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 Driver's name:";
  cin >> name;
  while(true)
  {
   cout<<"how many drives will be judged for this driver";
   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)";
  }
   i =0;
   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(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 printMenu()
{
cout<<" Menu ";
cout<<"Asu- Driving Competition -2011 ";
cout<<"----------------------------------------- ";
cout<<"Drive Difficulty ";
cout<<"1.Forward Jump Pike 1.0 ";
cout<<"2.Forward Dive Straight 1.6 ";
cout<<"3.Forward 2.5 Tuck 2.2 ";
cout<<"4.Back 3.5 Tuck 3.4 ";
cout<<"5.Inward 0.5 Twist Straight 1.9 ";
cout<<"----------------------------------------- ";
}

void printResult(int Score[],int scoresCount,float difficulty,string name)
{
float total,avg;
int sum = 0;
for(int i=0;i<scoresCount;i++)
  sum += Score[i];
total = sum * difficulty;
avg = (float)sum / scoresCount;
cout<<"Asu- Driving Competition -2011 ";
cout<<"Driving Scores for "<<name;
cout<<"----------------------------------------- ";
cout<<" Drive Difficulty Total Average";
cout<<" dname "<<difficulty<<" "<<total<<" "<<avg;

}