SProject 6 Description in Project 6, you will write a computer program that comp
ID: 3793677 • Letter: S
Question
SProject 6 Description in Project 6, you will write a computer program that computes ballroom dance competition scores given the individual scores provided by the four judges Judges rate a couples performance on a scale from 0.0-5.0 with 5.0 being the best possible score and 0.0 being the worst possible score. The lowest score for each couple is discarded and the remaining three scores are averaged to compute the couples final score. Your program must also determine the couples' performance level based upon their overall score. Overall score Range Performance Level 0.0 s overall score 1.0 Division IV 1.0 S overall score 2.0 Division III 2.0 s overall score 3.0 Division II 3.0 s overall score 4.0 Division I 4.0 s overall score s 5.0 Masters Division Out of range value Invalid Score (any scoreExplanation / Answer
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main(void){
double Judge1, Judge2, Judge3, Judge4, score, min;
ifstream myfile;
string fileLocation;
//gets file location from the user
cout<<"Enter the file Location";
getline(cin, fileLocation);
//open the file
myfile.open(fileLocation);
//check the file opened properly or not
while(myfile.fail){
cout<<"The file at Location "<<fileLocation<<" Failed to open file";
cout<<"Please enter the Location of file";
getline(cin, fileLocation);
myfile.open(fileLocation);
}
//read all data from the file
myfile>>Judge1>>Judge2>>Judge3>>Judge4;
//first calculate total score of all Judges, then later we discard min
score=Judge1+Judge2+Judge3+Judge4;
//let Judge1 score is minumum of all
min=Judge1;
if(Judge2<=min){
min=Judge2;
}
if(Judge3<=min){
min=Judge3;
}
if(Judge4<=min){
min=Judge4;
}
//now we discarding the minimum score by subtracting score-min
score=(score-min)/3;
if(score>5)
cout<<"Invalid Score";
else if(score>=4)
cout<<"Master Division";
else if(score>=3)
cout<<"Division I";
else if(score>=2)
cout<<"Division II";
else if(score>=1)
cout<<"Division III";
else if(score>=0)
cout<<"Division IV";
else
cout<<"Invalid Score";
cin.ignore();
return 0;
}
//now take a test case 4.3, 3, 5, 2 here min is 2 so it discard and Overall Score=12.3/3=4.1 so Master Division
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.