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

#include<iostream> using namespace std; //Function prototypes void ascending(dou

ID: 3627899 • Letter: #

Question

#include<iostream>
using namespace std;

//Function prototypes
void ascending(double[], int);
void descending(double[], int);
void highest();
void lowest();
void average();

//Global Variables
int count = 0;
int NUM_SCORES;
double scores;
double total = 0;

int main()
{



cout<<"THIS PROGRAM WILL READ AT MOST 150 SCORES. THEN IT WILL"<<endl;
cout<<"PRINT THE LIST OF SCORES, THE SCORES FROM LOWEST TO HIGHEST,"<<endl;
cout<<"THE SCORES FROM HIGHEST TO LOWEST, THE HIGHEST SCORE, THE LOWEST SCORE"<<endl;
cout<<"AND THE AVERAGE OF THE SCORES."<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;



//Ascending Order
ascending(scores[150], NUM_SCORES);

//Descending Order
descending(scores[150], NUM_SCORES);

//Highest
highest();

//Lowest
lowest();

//Average
average();

return 0;

}

void ascending(double scores[], int NUM_SCORES)
{
cout<<"How Many Scores Do You Want To Enter?";
cin>>NUM_SCORES;
while(count<NUM_SCORES)
{
cout<<"Please Enter Score"<<" "<<++count<<":";
cin>>scores[NUM_SCORES];
for(int count = 0; count< NUM_SCORES;count++)
{
total += scores[count];
}
}

int minInd;
double minVal;

for(; count<(NUM_SCORES-1); count++)
{
minInd = count;
minVal = scores[count];
for(int ind = count + 1; ind < NUM_SCORES; ind++)
{
if(scores[ind] < minVal)
{
minVal = scores[ind];
minInd = ind;
}
}
scores[minInd] = scores[count];
scores[count] = minVal;
}

cout<<" The ASCENDING ORDER Is:";
for(count=0; count<NUM_SCORES; count++)
cout<<scores[count]<<" ";
cout<<endl;
}

void descending(double scores[], int NUM_SCORES)
{

int maxInd;
double maxVal;

for(; count<(NUM_SCORES-1); count++)
{
maxInd=count;
maxVal = scores[count];

for(int ind = count + 1; ind<NUM_SCORES; ind++)
{
if(scores[ind] > maxVal)
{
maxVal=scores[ind];
maxInd=ind;
}
}
scores[maxInd]=scores[count];
scores[count]=maxVal;
}
}

void highest()
{
int count;
double highest;

highest = scores[0];
for(count=1; count<NUM_SCORES; count++)
{
if (scores[count] > highest)
highest = scores[count];
}
cout<<"The HIGHEST NUMBER Is:";
cout<<scores[count]<<" "<<endl;
}

void lowest()
{
int count;
double lowest;

lowest = scores[0];
for(count=1; count<NUM_SCORES; count++)
{
if (scores[count] < lowest)
lowest = scores[count];
}
cout<<"The LOWEST NUMBER Is:"<<lowest<<endl;
}

void average()
{
cout<<"AVERAGE Is:"<<total/NUM_SCORES<<endl;
}

gives error
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(31): error C2109: subscript requires array or pointer type
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(34): error C2109: subscript requires array or pointer type
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(117): error C2109: subscript requires array or pointer type
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(120): error C2109: subscript requires array or pointer type
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(121): error C2109: subscript requires array or pointer type
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(124): error C2109: subscript requires array or pointer type
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(132): error C2109: subscript requires array or pointer type
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(135): error C2109: subscript requires array or pointer type
c:documents and settingsusermy documents isual studio 2010projects est est est.cpp(136): error C2109: subscript requires array or pointer type

thx 4 help

Explanation / Answer

please rate - thanks

it wasn't clear if you wanted globals or parameters, so I made it all parameters

#include<iostream>
using namespace std;

//Function prototypes
void ascending(double[], int&,double&);
void descending(double[], int);
void highest(double[], int);
void lowest(double[], int);
void average(double,int);

//Global Variables


int main()
{double scores[150];
int count = 0;
int NUM_SCORES=0;
double total = 0;


cout<<"THIS PROGRAM WILL READ AT MOST 150 SCORES. THEN IT WILL"<<endl;
cout<<"PRINT THE LIST OF SCORES, THE SCORES FROM LOWEST TO HIGHEST,"<<endl;
cout<<"THE SCORES FROM HIGHEST TO LOWEST, THE HIGHEST SCORE, THE LOWEST SCORE"<<endl;
cout<<"AND THE AVERAGE OF THE SCORES."<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;



//Ascending Order
ascending(scores, NUM_SCORES,total);

//Descending Order
descending(scores, NUM_SCORES);

//Highest
highest(scores, NUM_SCORES);

//Lowest
lowest(scores, NUM_SCORES);

//Average
average(total,NUM_SCORES);
system("pause");
return 0;

}

void ascending(double scores[], int& NUM_SCORES,double& total)
{int count=0;
cout<<"How Many Scores Do You Want To Enter?";
cin>>NUM_SCORES;
while(count<NUM_SCORES)
{
cout<<"Please Enter Score"<<" "<<count+1<<":";
cin>>scores[count];

total += scores[count];
count++;
}


int minInd,ind;
double minVal,t;
count=0;

for(; count<(NUM_SCORES-1); count++)
{minInd = count;
minVal = scores[count];

for(ind = count + 1; ind < NUM_SCORES; ind++)
{
    if(scores[ind] < minVal)
        {
          minVal = scores[ind];
          minInd = ind;
        }

       
}
t=scores[minInd];
scores[minInd] = scores[count];
scores[count] = t;
}

cout<<" The ASCENDING ORDER Is:";
for(count=0; count<NUM_SCORES; count++)
cout<<scores[count]<<" ";
cout<<endl;
}

void descending(double scores[], int NUM_SCORES)
{

int maxInd,ind;
double maxVal,t;
int count=0;
for(; count<(NUM_SCORES-1); count++)
{
maxInd=count;
maxVal = scores[count];

for(ind = count + 1; ind<NUM_SCORES; ind++)
{
if(scores[ind] > maxVal)
{
maxVal=scores[ind];
maxInd=ind;
}

}
t=scores[maxInd];
scores[maxInd]=scores[count];
scores[count]=t;
}
cout<<" The DECENDING ORDER Is:";
for(count=0; count<NUM_SCORES; count++)
cout<<scores[count]<<" ";
cout<<endl;
}

void highest(double scores[], int NUM_SCORES)
{
int count;
double highest;

highest = scores[0];
for(count=1; count<NUM_SCORES; count++)
{
if (scores[count] > highest)
     highest = scores[count];
}
cout<<"The HIGHEST NUMBER Is:";
cout<<highest<<" "<<endl;
}

void lowest(double scores[], int NUM_SCORES)
{
int count;
double lowest;

lowest = scores[0];
for(count=1; count<NUM_SCORES; count++)
{
if (scores[count] < lowest)
lowest = scores[count];
}
cout<<"The LOWEST NUMBER Is:"<<lowest<<endl;
}

void average(double total,int NUM_SCORES)
{
cout<<"AVERAGE Is:"<<total/NUM_SCORES<<endl;
}