Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Language Create a void getInput function which will input both name and test score. Create a void assignGrade function which will use the test

C++ Language

Create a void getInput function which will input both name and test score.

Create a void assignGrade function which will use the test array to fill the grade array

Create a value returning calcAvg function which uses the test array to return the class average

Create a value returning findHi function which uses the test array to find the index of the student with the high score and returns the index

Create a value returning findLow function which uses the test array to find the index of the student with the low score and returns the index

Create a void displayResults function which takes as parameters the name array, test array, grade array, size, average, lowIndex and hiIndex to display all the output that was displayed in Program.

**This is what I have so far**

#include #include using namespace std;

int main() {

const int NUM_STUDENTS = 4; string name[NUM_STUDENTS]; int test[NUM_STUDENTS]; char grade[NUM_STUDENTS]; float avg; int total = 0, hiIndex = 0, loIndex = 0;

for (int counter = 0; counter < NUM_STUDENTS; counter++) { // get student name cout << "Input the student name and press enter "; getline(cin, name[counter]);

//get student test score cout << "Input the score for midter test "; cin >> test[counter]; cin.ignore();

// (accumulate scores) total all scores total += test[counter];

//assign letter grade if (test[counter] >= 90) grade[counter] = 'A'; else if (test[counter] >= 80) grade[counter] = 'B'; else if (test[counter] >= 70) grade[counter] = 'C'; else if (test[counter] >= 60) grade[counter] = 'D'; else grade[counter] = 'F';

//find index of student with highest score if (test[hiIndex] < test[counter]) hiIndex = counter; // save the index of the high student if (test[loIndex] > test[counter]) loIndex = counter; // save the index of the low student }

// calculate the class average avg = static_cast(total) / NUM_STUDENTS;

//display results for (int counter = 0; counter < NUM_STUDENTS; counter++) { cout << name[counter] << ", your test score = " << test[counter] << ", your grade = " << grade[counter] << endl;

}

cout << " The class average for this test = " << avg << endl << endl;

cout << name[hiIndex] << " has the highest test score = " << test[hiIndex] << endl; cout << name[loIndex] << " has the lowest test score = " << test[loIndex] << endl; system("pause"); return 0; }

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions