Write a void function to find the average score on each test and store in an array testAvgs. Write a void function to print the average score for each student, i.e. print the contents of the array studentAvgs. The output will be well formatted and accompanied with appropriate messages. Write a void function to print the average score on each test, i.e. print the contents of the array testAvgs. The output will be well formatted and accompanied with appropriate messages. Add the following declaration for the array studentsPassing in the function main. bool studentsPassing[MAX_STUDENTS]; Write a function that initializes all components of the array studentsPassing to false. The array studentsPassing is a parameter. void Initialize(bool studentsPassing[],int numberOfStudents) Write a function that has studentsPassing , studentAvgs, and numberOfStudents as parameters.  Set the components of passing to true whenever the corresponding value in studentAvgs is greater than or equal to 50.0 Write a function that has studentsPassing as parameter and print the number of students who passed, i.e. count and print the number of components in studentsPassing that are true. It will also print which students passed.  Display meaningful messages. Write a function that has studentAvgs and numberOfStudents as parameters, and determine the highest average score of the class. This value and the student number with this value will be formatted and printed with an appropriate message. Complete the program with the functions and the appropriate function calls. Use the following code and add the above functions in the code, make sure you add all the functions in the program: #include using namespace std; const int MAX_STUDENTS = 30; const int MAX_TESTS = 10; //function to read each student scores from user void ReadScore(double scores[][MAX_TESTS], int& numberOfStudents, int& numberOfTests) { int student, test; cout << "Enter number of students: "; cin >> numberOfStudents; cout << "Number of tests: "; cin >> numberOfTests; for (student = 0; student < numberOfStudents; student++) { cout << "Enter " << numberOfTests << " scores of student " << student + 1 << ": " << endl; for (test = 0; test < numberOfTests; test++) { cin >> scores[student][test];}}} void PrintScore(double scores[][MAX_TESTS], int numberOfStudents, int numberOfTests) { int student, test; for (student = 0; student < numberOfStudents; student++) { cout << "The test score for student " << student + 1 << " are: " << endl; for (test = 0; test < numberOfTests; test++) { cout << scores[student][test] << " ";} cout << endl; }}void AverageScore(double scores[][MAX_TESTS], int numberOfStudents, int numberOfTests, double studentAverage[]) { double total; int student, test; for (student = 0; student < numberOfStudents; student++) { total = 0; for (test = 0; test < numberOfTests; test++) { total += scores[student][test]; } studentAverage[student] = total / numberOfTests; }} void PrintAverageScore(int numberOfStudents, double studentAverage[]) { int student; for (student = 0; student < numberOfStudents; student++) { cout << "Average score of student " << student + 1 << " is: " << studentAverage[student] << endl;}} //function to initilize passing array for each student to false void Initialize(bool passing[MAX_STUDENTS], int numberOfStudents) { int student; for (student = 0; student < numberOfStudents; student++) { passing[student] = false;} //function to decide and set the passing arry //if ith student is passsed then passing[i]=true void SetPassing(bool passing[MAX_STUDENTS], double studentAverage[], int numberOfStudents) { int student; for (student = 0; student < numberOfStudents; student++) { if (studentAverage[student] >= 50) passing[student] = true;}} //function to print number of student passed in exam void PrintPassing(bool passing[MAX_STUDENTS], int numberOfStudents) { int count = 0, student; for (student = 0; student < numberOfStudents; student++) { if (passing[student] == true) count++; } cout << "Number of students passed= " << count << endl; } //function to print the srudent having highest average void PrintHighestAverageScore(int numberOfStudents, double studentAverage[]) { int highest_index = 0, student; for (student = 0; student < numberOfStudents; student++) { if (studentAverage[highest_index] < studentAverage[student]) highest_index = student; } cout << "The student with highest average= " << highest_index + 1; } //main function int main() { double scores[MAX_STUDENTS][MAX_TESTS]; double studentAverage[MAX_STUDENTS]; int numberOfStudents; int numberOfTests; bool passing[MAX_STUDENTS]; cout << "WELCOME TO STUDENT EVALUTION SYSTEM" << endl; ReadScore(scores, numberOfStudents, numberOfTests); AverageScore(scores, numberOfStudents, numberOfTests, studentAverage); PrintAverageScore(numberOfStudents, studentAverage); Initialize(passing, numberOfStudents); PrintScore(scores, numberOfStudents, numberOfTests); SetPassing(passing, studentAverage, numberOfStudents); PrintPassing(passing, numberOfStudents); PrintHighestAverageScore(numberOfStudents, studentAverage); }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 23PE
icon
Related questions
Question

Write a void function to find the average score on each test and store in an array testAvgs.

Write a void function to print the average score for each student, i.e. print the contents of the array studentAvgs. The output will be well formatted and accompanied with appropriate messages.

Write a void function to print the average score on each test, i.e. print the contents of the array testAvgs. The output will be well formatted and accompanied with appropriate messages.

Add the following declaration for the array studentsPassing in the function main.

bool studentsPassing[MAX_STUDENTS];

Write a function that initializes all components of the array studentsPassing to false. The array studentsPassing is a parameter.

void Initialize(bool studentsPassing[],int numberOfStudents)

Write a function that has studentsPassing , studentAvgs, and numberOfStudents as parameters.  Set the components of passing to true whenever the corresponding value in studentAvgs is greater than or equal to 50.0

Write a function that has studentsPassing as parameter and print the number of students who passed, i.e. count and print the number of components in studentsPassing that are true. It will also print which students passed.  Display meaningful messages.

Write a function that has studentAvgs and numberOfStudents as parameters, and determine the highest average score of the class. This value and the student number with this value will be formatted and printed with an appropriate message. Complete the program with the functions and the appropriate function calls.

Use the following code and add the above functions in the code, make sure you add all the functions in the program:

#include<iostream>
using namespace std;
const int MAX_STUDENTS = 30;
const int MAX_TESTS = 10;

//function to read each student scores from user
void ReadScore(double scores[][MAX_TESTS], int& numberOfStudents, int& numberOfTests)
{
int student, test;
cout << "Enter number of students: ";
cin >> numberOfStudents;
cout << "Number of tests: ";
cin >> numberOfTests;
for (student = 0; student < numberOfStudents; student++)
{
cout << "Enter " << numberOfTests << " scores of student " << student + 1 << ": " << endl;
for (test = 0; test < numberOfTests; test++)
{
cin >> scores[student][test];}}}
void PrintScore(double scores[][MAX_TESTS], int numberOfStudents, int numberOfTests)
{
int student, test;
for (student = 0; student < numberOfStudents; student++)
{
cout << "The test score for student " << student + 1 << " are: " << endl;
for (test = 0; test < numberOfTests; test++)
{
cout << scores[student][test] << " ";}
cout << endl; }}void AverageScore(double scores[][MAX_TESTS], int numberOfStudents, int numberOfTests, double studentAverage[])
{
double total;
int student, test;
for (student = 0; student < numberOfStudents; student++)
{
total = 0;
for (test = 0; test < numberOfTests; test++)
{
total += scores[student][test];
}

studentAverage[student] = total / numberOfTests; }}

void PrintAverageScore(int numberOfStudents, double studentAverage[])
{
int student;
for (student = 0; student < numberOfStudents; student++)
{
cout << "Average score of student " << student + 1 << " is: " << studentAverage[student] << endl;}}
//function to initilize passing array for each student to false
void Initialize(bool passing[MAX_STUDENTS], int numberOfStudents)
{
int student;
for (student = 0; student < numberOfStudents; student++)
{
passing[student] = false;}
//function to decide and set the passing arry
//if ith student is passsed then passing[i]=true
void SetPassing(bool passing[MAX_STUDENTS], double studentAverage[], int numberOfStudents)
{
int student;
for (student = 0; student < numberOfStudents; student++)
{
if (studentAverage[student] >= 50)
passing[student] = true;}}

//function to print number of student passed in exam
void PrintPassing(bool passing[MAX_STUDENTS], int numberOfStudents)
{
int count = 0, student;
for (student = 0; student < numberOfStudents; student++)
{
if (passing[student] == true)
count++;
}
cout << "Number of students passed= " << count << endl;
}

//function to print the srudent having highest average
void PrintHighestAverageScore(int numberOfStudents, double studentAverage[])
{

int highest_index = 0, student;
for (student = 0; student < numberOfStudents; student++)
{
if (studentAverage[highest_index] < studentAverage[student])
highest_index = student;
}
cout << "The student with highest average= " << highest_index + 1;
}


//main function
int main()
{
double scores[MAX_STUDENTS][MAX_TESTS];
double studentAverage[MAX_STUDENTS];
int numberOfStudents;
int numberOfTests;
bool passing[MAX_STUDENTS];

cout << "WELCOME TO STUDENT EVALUTION SYSTEM" << endl;
ReadScore(scores, numberOfStudents, numberOfTests);

AverageScore(scores, numberOfStudents, numberOfTests, studentAverage);
PrintAverageScore(numberOfStudents, studentAverage);
Initialize(passing, numberOfStudents);
PrintScore(scores, numberOfStudents, numberOfTests);
SetPassing(passing, studentAverage, numberOfStudents);
PrintPassing(passing, numberOfStudents);
PrintHighestAverageScore(numberOfStudents, studentAverage);
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning