Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this assignment, you will: Write a program that explores the seating patterns

ID: 3781428 • Letter: I

Question

In this assignment, you will: Write a program that explores the seating patterns related to course performance by using an array of student scores. The program should do the following: Draw a seating chart of the classroom. Show where people sit and use color coding on the seats to indicate the student's current level of performance. The color-coding scheme should be as follows: Red—For students who are below the class mean Yellow—For students who are at or above the mean but below 90 percent Green—For students who are in the top 10 percent The program should use the following: A two-dimensional array of student scores instead of a one-dimensional array. The two-dimensional array of scores having the same number of rows and columns as the arrangement of seats in the classroom. Save the program as Seating.cpp. Having trouble with the color coding of the seating

Explanation / Answer

CPP CODE:

#include<iostream>

using namespace std;

int main()
{
   // I have taken a 2x4 marksay.
   // The marks entered here are for a total of 100 marks.
   int marks[2][4] = {{10,20,60,90},
                   {95,98,45,32}};

   // Create a color array of same dimension as marks array.
   char color[2][4];

   // Variable to calculate mean.
   float mean = 0;

   // variable to calculate sum.
   int sum = 0;

   // to store total number of students.
   int totalStudents = 0;

   // calculate total number of students and the marks scored by them.
   for (int i=0;i<2;i++){
       for(int j=0;j<4;j++){
           sum += marks[i][j];
           totalStudents++;
       }
   }

   // calculate mean
   mean = sum/totalStudents;

   for(int i=0;i<2;i++){
       for(int j=0;j<4;j++){
           // If the marks is less than mean then store color Red in the color array.
           if (marks[i][j] < mean){
               color[i][j] = 'R';   // --- R represents RED color.
           }
           // If the marks is greater than mean and less than 90% then store color Yellow in the color array.
           else if ((marks[i][j] >= mean) && (marks[i][j] < 90)){
               color[i][j] = 'Y'; // -- Y represents YELLOW color.
           }
           // If the marks is greater than 90% store GREEN color.
           else{
               color[i][j] = 'G';   // -- G represents GREEN color.
           }
       }
   }

   // Display the result.
   for (int i=0;i<2;i++){
       for(int j=0;j<4;j++){
           cout << color[i][j] << " ";
       }
       cout << endl;
   }
}

OUTPUT:

$ ./a.out
R   R   Y   G  
G   G   R   R