/Purpose: This program reads data for a computer science closed lab section. //
ID: 3618016 • Letter: #
Question
/Purpose: This program reads data for a computer science closed lab section.// Add a code to print the scores so that each student's labs appear
// on a separate line of output. Your output should be labeled as follows:
/*
Student 1: 80 90 70 100 60 90 85 78 93 80 70 98 89 94
Student 2: 98 85 100 99 89 90 72 0 78 98 100 65 0 56
Student 3: 85 60 25....
.
.
*/
//Input: The first two entries in the input are the number of students
// in the class and the number of closed labs the class has finished.
// For each student, their closed labs are input from the
// following lines of the file.
//
//Limitations: It is assumed that there will be no more than MAX_STUDENTS students
// in the class and there will be no more than MAX_LABS labs.
//include files...
#include <iostream>
using namespace std;
//global constants...
const int MAX_STUDENTS=40; //maximum number of students
const int MAX_LABS=14; //maximum number of closed labs
int main()
{
//local declarations...
int numStudents; //how many students are in the class
int numLabs; //how many closed labs
int labScores[MAX_STUDENTS][MAX_LABS]; //holds lab scores
int student; //controls which student's labs are read
int lab; //controls which lab is being read
//read in the data for all students in the class
//get the number of students in the class
cin >> numStudents >> numLabs;
//outer loop controls which student(row) is being read
for (student = 0; student < numStudents; student++)
{
//inner loop controls which lab(column) is being read
for (lab = 0; lab < numLabs; lab++)
cin >> labScores[student][lab];
}
//print the data for all students in the class
// Add a code to print the scores so that each student's labs appear// on a separate line of output. Your output should be labeled as follows:Student 1: 80 90 70 100 60 90 85 78 93 80 70 98 89 94Student 2: 98 85 100 99 89 90 72 0 78 98 100 65 0 56Student 3: 85 60 25....//there should be a nested loop//outer loop controls which student(row) is being read
//end of main...
return 0;
}
Explanation / Answer
please rate - thanks //Purpose: This program reads data for acomputer science closed lab section. // Add a code to print the scores so that each student's labsappear // on a separate line of output. Your output should belabeled as follows: /* Student 1: 80 90 70 100 60 90 85 78 93 80 70 98 89 94 Student 2: 98 85 100 99 89 90 72 0 78 98100 65 0 56 Student 3: 85 60 25.... . . */ //Input: The first two entriesin the input are the number of students // in the class and the number of closed labs the class hasfinished. // For each student, their closed labs are input from the // following lines of the file. // //Limitations: It is assumed that there will be no more thanMAX_STUDENTS students // in the class and there will be no morethan MAX_LABS labs. //include files... #include using namespace std; //global constants... const intMAX_STUDENTS=40; //maximum number of students const intMAX_LABS=14; //maximum number of closed labs int main() { //local declarations... intnumStudents; //how many students are in the class intnumLabs; //how many closed labs intlabScores[MAX_STUDENTS][MAX_LABS]; //holds labscores intstudent; //controls which student's labs are read intlab; //controls which lab is being read //read in the data for all students in the class //get the number of students in the class cin >> numStudents >> numLabs; //outer loop controls which student(row) is beingread for (student = 0; student labScores[student][lab]; } //print the data for all students in the class // Add a code to print the scores so that eachstudent's labs appear// on a separate line of output.Your output should be labeled as follows:
Student 1: 8090 70 100 60 90 85 78 93 80 70 98 89 94
Student 2: 98 85100 99 89 90 72 0 78 98 100 65 0 56
Student 3: 85 6025....
//there should be a nested loop
//outerloop controls which student(row) is being read
for(student=0;student
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.