Attached Files astarsDancetxt 304 B Due Tuesday 1129 12pm 50

Attached Files: astarsDance.txt (304 B) Due Tuesday, 11/29, 12pm, 50pts A particular talent competition has four judges each of whom awards a score between 0 and 10 each. Fractional scores are allowed. A performer\'s final score is determined by dropping the lowest score received and then averaging the three remaining scores. Write a program that uses this method to calculate a contestant\'s scores. Note: read the contestants name and scores from an input file starsDance.bxt attached. There will be 10 contestants. The program will need the following functions: void get udge Data0 reads the name of the contestant and his or her scores. Scores should be validated (between 0 and 10) void calcscore0 should calculate and display the average of the three scores that remain after dropping the lowest score the performer received. This function should be passed the four scores. Your program should also print the name and score of the winner-the person with the highest average Score.

Solution

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
string ff,lf;
double score;
void calcScore(double s1,double s2,double s3,double s4)
{
       double min=10;
       if(s1>0 && s1<10 && s1<min)
       {
           min=s1;
       }
       if(s2>0 && s2<10 && s2<min)
       {
           min=s2;
       }
       if(s3>0 && s3<10 && s3<min)
       {
           min=s3;
       }
       if(s4>0 && s4<10 && s4<min)
       {
           min=s4;
       }
       double avg = (s1+s2+s3+s4-min)/3;
       cout<<avg<<endl;
}
void getJudgeData()
{
   string f,l;
   ifstream myf(\"starsDance.txt\");
   double s1,s2,s3,s4;
   for(int i=0;i<10;i++)
   {
       myf>>f;
       myf>>l;
       myf>>s1;
       myf>>s2;
       myf>>s3;
       myf>>s4;
       cout<<f<<\" \"<<l<<\" \";
   calcScore(s1,s2,s3,s4);
   }
  
}

int main()
{
   getJudgeData();
   return 0;
}

 Attached Files: astarsDance.txt (304 B) Due Tuesday, 11/29, 12pm, 50pts A particular talent competition has four judges each of whom awards a score between 0 a
 Attached Files: astarsDance.txt (304 B) Due Tuesday, 11/29, 12pm, 50pts A particular talent competition has four judges each of whom awards a score between 0 a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site