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

can someone helps me to rewrite this: Rewrite the solution to the Star Search pr

ID: 3577305 • Letter: C

Question

can someone helps me to rewrite this:

Rewrite the solution to the Star Search problem, see page 370 Programming Challenges, to use a dynamic array. Read the number of judges from the standard input device. Make sure the user enters numeric input; make sure that number of judges is greater than 0. Create a dynamic array, using the new operator, to store the judges' scores.

#include <iostream>

#include <string>

#include <iomanip>

using namespace std;

void getJudgeData(double&);

void calcScore(double,double,double,double,double);

double findLowest(double,double,double,double,double);

double findHighest(double,double,double,double,double);

int main()

//variable

{double score1,score2,score3,score4,score5;

char yesno;

// do while loop

do

{

getJudgeData(score1);

getJudgeData(score2);

getJudgeData(score3);

getJudgeData(score4);

getJudgeData(score5);

calcScore(score1,score2,score3,score4,score5);

cout<<"Do you want to enter another set of scores? (y/n) ";

cin>>yesno;

}

while(yesno=='y'||yesno=='Y');

return 0;

}

void getJudgeData(double &s)

{cout << "Enter score between 0 and 10: ";

cin>>s;

// validtion range number

while(s <0 || s> 10)

{cout<<"Score must be in the range 0 - 10. Please enter the score again: ";

cin>> s;

}

}

void calcScore(double score1,double score2,double score3,double score4,double score5)

{

double sum,l,h;

l=findLowest(score1, score2, score3, score4, score5);

h=findHighest(score1, score2, score3, score4, score5);

sum=score1 + score2 + score3 + score4 + score5 - l - h;

cout<<"This contestant's talent score is: "<<setprecision(2)<<fixed<<sum/3.<<endl;

}

double findLowest(double score1,double score2,double score3,double score4,double score5)

{double low=score1;

if(score2 < low)

low = score2;

if(score3 < low)

low = score3;

if(score4 < low)

low = score4;

if(score5 < low)

low= score5;

return low;

}

double findHighest(double score1,double score2,double score3,double score4,double score5)

{ double high = score1;

if(score2 > high)

high = score2;

if(score3 > high)

high= score3;

if(score4 > high)

high = score4;

if(score5 > high)

high = score5;

return high;

}

Explanation / Answer

PROGRAM CODE:

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
void getJudgeData(double&);
void calcScore(double[], int);
double findLowest(double[], int);
double findHighest(double[], int);
int main()
//variable
{
int numOfJudges = 0;
cout<<"Enter the number of Judges: ";
cin>>numOfJudges;
while(numOfJudges <0)
{cout<<"Number of judges must be numeric and positive. Please enter again: ";
cin>> numOfJudges;
}
double* scores = new double[numOfJudges]();
double score;
char yesno;
// do while loop
do
{
   for(int i=0; i<numOfJudges; i++)
   {
       getJudgeData(score);
       scores[i] = score;
   }

calcScore(scores, numOfJudges);
cout<<"Do you want to enter another set of scores? (y/n) ";
cin>>yesno;
}
while(yesno=='y'||yesno=='Y');
return 0;
}

void getJudgeData(double &s)
{cout << " Enter score between 0 and 10: ";
cin>>s;
// validtion range number
while(s <0 || s> 10)
{cout<<"Score must be in the range 0 - 10. Please enter the score again: ";
cin>> s;
}
}

void calcScore(double scores[], int numOfScores)
{
double sum = 0,l,h;
l=findLowest(scores, numOfScores);
h=findHighest(scores, numOfScores);
for(int i=0; i<numOfScores; i++)
{
   sum += scores[i];
}
sum = sum - l - h;
cout<<" This contestant's talent score is: "<<setprecision(2)<<fixed<<sum/3.0<<endl;
}

double findLowest(double scores[], int numOfScores)
{
double low=scores[0];
for(int i=0; i<numOfScores; i++)
{
   if(low>scores[i])
       low = scores[i];
}
return low;
}

double findHighest(double scores[], int numOfScores)
{
double high = scores[0];
for(int i=0; i<numOfScores; i++)
{
   if(high<scores[i])
       high = scores[i];
}
return high;
}

OUTPUT:

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