Consider the following program that reads students’ test scores into an array and prints the contents of the array.   You will add more functions to the program.  The instructions are given below. For each of the following exercises, write a function and make the appropriate function call in main. Comments are to be added to the program.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Consider the following program that reads students’ test scores into an array and prints the contents of the array.   You will add more functions to the program.  The instructions are given below.

For each of the following exercises, write a function and make the appropriate function call in main.

Comments are to be added to the program.

 

  1. Write a void function to find the average test score for each student and store it in an array studentAvgs.

 

void AverageScores( const int scores[][MAX_TESTS],

                       int numberOfStudents,

                       int numberOfTests,

                       double studentAvgs[]);

 

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

 

 

3. 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.

4. 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.

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

 

bool studentsPassing[MAX_STUDENTS];

6. 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)

7. 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

 

8. 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.

9. 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.

10. Complete the program with the functions and the appropriate function calls. Run the program using the following test data:

Number of students :  5

Number of tests: 4

The test scores for the 5 students:

(note that each row represents the four test scores for one student)

69  80  90  95

70  90  65  85

50  50  60  60

40  45  30  50

25  35  45  49

Note: Your program will have good layout following the guidelines for program layout.  It will also have appropriate comments and function headers with good description.

Run the program again using at least two other data sets using a different number of students and tests for each test run.

Consider the following program that reads students' test scores into an amay and prints the contents of the
array. You will add more functiocns to the program. The instructioIs are given helow.
// Definition of function ReadScores
// This function reads each student's test scores into array scores
// The paraneter scores 1s an array to hold numbers between o and 100
// entered as teat aoores.
// The paraneter numberofstudents is a reference parameter to the number of
// studenta read.
// The parameter numberofTests is a reference paraneter to the nunber of
// testa read.
... add program identification header: block comment
include <1ontream
+include ciomanip>
using namespace std:
void Readscores (double scores() [MAX_TESTS), //array of test scores
/number o atudenta read
//constant declarations
conat int MAX_STUDENTS- 30:
const int MAX TESTS - 10:
//naximum number of atudents
/naximum nunber of tests
inta numberorstudents,
ints numberorTests)
//number of tests read
int student: //zow index used for atudents
int test:
//tunetion prototypes
/column index used for tests
void Readscores (double[] [MAX_TESTS), ints, ints):
void PrintScores (const double[1 (MAX_TESTS), int, int):
//prompt for and read the number of students and the number of tests
cout <'Enter the nunber of studenta (up to " MAX_SIUDENTS <« "): *:
cin >> nunberofstudenta
cout cc'Enter the nunber of teata (up to e MAX_TESTS « ): ":
cin >>
int main ()
//read the test scores into the array scores
for (student - 0; student <
//variable declarations
student++)
double scores (MAX_SIUDENTS] (MAXX_TESTS); //array of test scores
cout <c"Enter the - « numberorTesta
«* sest acores (0-100inelusive) for studente
« (student + 1) « endl;
int nunberorstudenta:
//number of students in a class
int nunberorfesta:
//number of testa vritten
vrite some code to display some title (s) about the program, and cansider
spacing
for (teat - 0: test e
cin > scores [atudent)
- teat)
/read each student's test scores into an array scores
Readscores
numberofstudenta,
//print each student's scores
PrintScores
To be completed
Print your name, some message before the program ends
systen("pause") :
return o
Transcribed Image Text:Consider the following program that reads students' test scores into an amay and prints the contents of the array. You will add more functiocns to the program. The instructioIs are given helow. // Definition of function ReadScores // This function reads each student's test scores into array scores // The paraneter scores 1s an array to hold numbers between o and 100 // entered as teat aoores. // The paraneter numberofstudents is a reference parameter to the number of // studenta read. // The parameter numberofTests is a reference paraneter to the nunber of // testa read. ... add program identification header: block comment include <1ontream +include ciomanip> using namespace std: void Readscores (double scores() [MAX_TESTS), //array of test scores /number o atudenta read //constant declarations conat int MAX_STUDENTS- 30: const int MAX TESTS - 10: //naximum number of atudents /naximum nunber of tests inta numberorstudents, ints numberorTests) //number of tests read int student: //zow index used for atudents int test: //tunetion prototypes /column index used for tests void Readscores (double[] [MAX_TESTS), ints, ints): void PrintScores (const double[1 (MAX_TESTS), int, int): //prompt for and read the number of students and the number of tests cout <'Enter the nunber of studenta (up to " MAX_SIUDENTS <« "): *: cin >> nunberofstudenta cout cc'Enter the nunber of teata (up to e MAX_TESTS « ): ": cin >> int main () //read the test scores into the array scores for (student - 0; student < //variable declarations student++) double scores (MAX_SIUDENTS] (MAXX_TESTS); //array of test scores cout <c"Enter the - « numberorTesta «* sest acores (0-100inelusive) for studente « (student + 1) « endl; int nunberorstudenta: //number of students in a class int nunberorfesta: //number of testa vritten vrite some code to display some title (s) about the program, and cansider spacing for (teat - 0: test e cin > scores [atudent) - teat) /read each student's test scores into an array scores Readscores numberofstudenta, //print each student's scores PrintScores To be completed Print your name, some message before the program ends systen("pause") : return o
//*
// Definition of function ReadScores
// This function reads each student's test scores into array scores
// The parameter scores is an array to hold numbers between 0 and 100
// entered as test scores.
// The parameter numberofStudents is a reference parameter to the number of
// students read.
// The parameter numberOfTests is a reference parameter to the number of
// tests read.
//*********
// Definition of function PrintScores
// This function prints each student's test scores
// The parameter scores is an array to hold each student's test scores
// The parameter numberofStudents holds the number of students integers
// The parameter numberofTests holds the number of tests.
//**
void PrintScores ( const double scores [] [MAX_TESTS],
int
int
void ReadScores (double scores [] [MAX_TESTS],//array of test scores
{
ints numberOfStudents,
ints numberofTests)
int student;
int test;
//number of students read
//number of tests read
{
int student; //row index used for students
for (student = 0; student <
{
; student++)
int test;
//column index used for tests
cout <<"The test scores for student# " <« (student + 1)
//prompt for and read the number of students and the number of tests
cout <<"Enter the number of students (up to " <« MAX_STUDENTS <« "): *;
cin >> numberofStudents;
<<" are: ";
for (test = 0; test <
cout << setw (3) << scores [
; test++)
cout <<"Enter the number of tests (up to " « MAX_TESTS <« ") : ;
cin >>
cout « endl;
//read the test scores into the array scores
for (student = 0; student <
{
student++)
cout <<"Enter the " << numberofTests
« " test scores (0-100inclusive) for student# "
« (student + 1) << endl;
for (test = 0; test <
cin >> scores [student]
For each of the following exercises, write a function and make the appropriate func-
tion call in main.
; test++)
Comments are to be added in the program.
}
1. Write a void function to find the average test score for each student and store in an ar-
ray studentAvgs.
void AverageScores ( const int scores [] [MAX TESTS],
Transcribed Image Text://* // Definition of function ReadScores // This function reads each student's test scores into array scores // The parameter scores is an array to hold numbers between 0 and 100 // entered as test scores. // The parameter numberofStudents is a reference parameter to the number of // students read. // The parameter numberOfTests is a reference parameter to the number of // tests read. //********* // Definition of function PrintScores // This function prints each student's test scores // The parameter scores is an array to hold each student's test scores // The parameter numberofStudents holds the number of students integers // The parameter numberofTests holds the number of tests. //** void PrintScores ( const double scores [] [MAX_TESTS], int int void ReadScores (double scores [] [MAX_TESTS],//array of test scores { ints numberOfStudents, ints numberofTests) int student; int test; //number of students read //number of tests read { int student; //row index used for students for (student = 0; student < { ; student++) int test; //column index used for tests cout <<"The test scores for student# " <« (student + 1) //prompt for and read the number of students and the number of tests cout <<"Enter the number of students (up to " <« MAX_STUDENTS <« "): *; cin >> numberofStudents; <<" are: "; for (test = 0; test < cout << setw (3) << scores [ ; test++) cout <<"Enter the number of tests (up to " « MAX_TESTS <« ") : ; cin >> cout « endl; //read the test scores into the array scores for (student = 0; student < { student++) cout <<"Enter the " << numberofTests « " test scores (0-100inclusive) for student# " « (student + 1) << endl; for (test = 0; test < cin >> scores [student] For each of the following exercises, write a function and make the appropriate func- tion call in main. ; test++) Comments are to be added in the program. } 1. Write a void function to find the average test score for each student and store in an ar- ray studentAvgs. void AverageScores ( const int scores [] [MAX TESTS],
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY