Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago