Question: 1) Grades with input validation (C++). Modify grade programs with arrays and functions. (the program should minimally have functions for average, min, max, # above

1) Grades with input validation (C++). Modify grade programs with arrays and functions. (the program should minimally have functions for average, min, max, # above average, etc. total of 4 functions) Add logic (to the main) so that if the user enters an invalid grade (lower than zero, higher than 100), the user will be issued an error message and then be allowed to reenter the grade. This will repeat as long as the user enters invalid grades. You will need a While loop. (See next slide for hints.) (filename = "grade-validation.cpp"). Include adequate testing and sample output. 2) Selection Sort (C++). Add selection sort function to grade program above. Program should display list of grades in sorted ascending order. (filename = "grade-sort.cpp"). Include testing and sample output. (Hint: do not modify the selection sort function in any way!!)

I need help in part 2 heres the selection sort function you cant change

void sort(double x[], int npts) { double min_value; int min_index; double temp; for(int i= 0; i

and heres the code temp = x[min_index]; x[min_index] = x[i]; x[i] = temp; } return; }

and here my code for the main function

#include using namespace std;

double average(double x[], int n); double maximum(double x[], int n); double minimum(double x[], int n); int nAboveAvg(double x[], int n); void sort(double x[], int npts);

int main() { double grades[50]; int ngrades; cout<<"How many grades? (max = 50) "; cin>>ngrades; //create for loop to get grades from user for(int i = 0; i> grades[i]; while(grades[i]< 0 || grades[i] > 100) { cout<<"Invalid grade- please enter again"<>grades[i]; } } //call the functions double avg = average(grades, ngrades); double max = maximum(grades, ngrades); double min = minimum(grades, ngrades); int nAbove = nAboveAvg(grades, ngrades); sort(grades, ngrades); //display results

cout << "Average = " << avg << endl; cout << "# above average = " << nAbove << endl; cout<<"Max value is = "<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!