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

Write a program in C or C++. (arrays) There are three options available to the u

ID: 3685359 • Letter: W

Question

Write a program in C or C++. (arrays)

There are three options available to the user: 1) CIS 32 2) Other Classes 3) Quit.

Maximum of 10 students for each option. When the user selects the first option

a) Ask for the student's Id (between 1 and 100 inclusive)? (Duplicates are not allowed)

b) Ask for the score earned on the midterm test (between 1 and 100 inclusive)

C) Ask for the score earned on the final test (between 1 and 100 inclusive)

(Note: The allocated size is the maximum size of the array which is 10 but the effective size is the number of times the user selects option 1)

When the user selects option 2

a) Ask for the student's Id (between 1 and 100:inclusive)? b) Ask for the class the student is taking (any integer number)? (The combination of student ID and class code must be unique.) c) How many scores do you want to record for the class that the student is taking (Between 2 to 4). (You are storing the effective size for each selection) d) Prompt the user for each of the scores. (Note: There are two effective sizes that we are interested in with this option. One is the number of times the user selects option 2. The other is the number of scores associated with each of the class (between 2 to 4). e.g. The user selects option 2 three times. Therefore the effective size is 3 while the allocated size which is the maximum that a user can select option 2 is ten. For each of the three times the user wants to record 2, 3 and 4 scores respectively. These would also be the effective size)

When the user selects option 3 a) Display the student ID , along with the recorded scores, calculated average score and the calculated letter grade from the first option, sorted according to the Student ID in ascending order using selection sort b) Display everything from the second option, along with the calculated average score and calculated letter grade for each of the classes, sorted according to the class code in descending order using bubble sort

Explanation / Answer

#include <iostream>

using namespace std;
/* Maximum of 10 students for each option*/
#define max 10
enum cases {"Option one", "Other classes", "Quit"
};
int main()
{
   int option;
   int id1[10];
   int midterm_score1[10];
   int finaltest_score1[10];
   int n1=0;//number of students
   int id2[10];
   int class_code2[10];
   int score_count[10];
   int scores[4][10];
   int n2=0;//number of students
   /*There are three options available to the user: 1) CIS 32 2) Other Classes 3) Quit.
*/
while(true){
   cout<<endl<<"Options";
   cout<<endl<<"1) CIS 32";
   cout<<endl<<"2) Other Classes";
   cout<<endl<<"3) Quit";
cout<<endl<<"Enter your option: ";
cin>>option;
switch(option)
{
        /* When the user selects the first option
a) Ask for the student's Id (between 1 and 100 inclusive)? (Duplicates are not allowed)
b) Ask for the score earned on the midterm test (between 1 and 100 inclusive)
C) Ask for the score earned on the final test (between 1 and 100 inclusive)
(Note: The allocated size is the maximum size of the array which is 10 but the effective
size is the number of times the user selects option 1)*/
    case cases.Option one:
        cout<<endl<<"Enter Student's ID: <1 to 100>";
        cin>>id1[n1];
        cout<<endl<<"Enter mid term test score: <1 to 100>";
        cin>>midterm_score1[n1];
        cout<<endl<<"Enter final test score: <1 to 100>";
        cin>>finaltest_score1[n1];
        n1++;
        break;
/*
When the user selects option 2
a) Ask for the student's Id (between 1 and 100:inclusive)?
b) Ask for the class the student is taking (any integer number)?
(The combination of student ID and class code must be unique.)
c) How many scores do you want to record for the class that the student is taking
(Between 2 to 4). (You are storing the effective size for each selection)
d) Prompt the user for each of the scores. (Note: There are two effective sizes
that we are interested in with this option. One is the number of times the user
   selects option 2. The other is the number of scores associated with each of the
   class (between 2 to 4). e.g. The user selects option 2 three times.
   Therefore the effective size is 3 while the allocated size which
   is the maximum that a user can select option 2 is ten. For each of the
three times the user wants to record 2, 3 and 4 scores respectively.
These would also be the effective size)*/
    case cases.Other classes:
        cout<<endl<<"Enter student id: ";
        cin>>id2[n2];
        cout<<endl<<"Enter class code: ";
        cin>>class_code2[n2];
        cout<<endl<<"Enter number of scores: <2 to 4>";
        cout<<endl<<score_count[n2];
        for(int i=0;i<score_count[n2];i++)
        {
        cin>>scores[n2][i];
       }
        break;
        /*When the user selects option 3 a) Display the student ID ,
       along with the recorded scores, calculated average score and the calculated letter grade
       from the first option, sorted according to the Student ID in ascending order using selection sort
       b) Display everything from the second option, along with the calculated average score
       and calculated letter grade for each of the classes,
       sorted according to the class code in descending order using bubble sort*/
    case cases.Quit:
        cout<<endl<<"CIS 32";
        double average1[n1];
        char grade1[n1];
        double sum;
        for(int i=0;i<n1;i++)
        {
            average1[i]=(midterm_score1[i]+finaltest_score1[i])/2;
            if(average1[i]>=90)
                grade1[i]='A';
            else if(average1[i]>=80 && average1[i]<90)
                grade1[i]='B';
            else if(average1[i]>=70 && average1[i]<80)
                grade1[i]='C';
            else if(average1[i]>= &60& average1[i]<70)
                grade1[i]='D';  
   }
   //selection sort
   int loc;
for (int i = 0; i < n1; ++i)
{
loc = i;

for (int j = i + 1; j < n1; ++j)
{
if (id1[j] < id1[loc])
{
  
loc = j;
}
}

//Swap the values
int t=id1[i];
id1[i]=id1[loc];
id1[loc]=t;
  
t=finaltest_score1[i];
finaltest_score1[i]=finaltest_score1[loc];
finaltest_score1[loc]=t;
  
t=midterm_score1[i];
midterm_score1[i]=midterm_score1[loc];
midterm_score1[loc]=t;
  
char tt=grade1[i];
grade1[i]=grade1[loc];
grade1[loc]=tt;
  
double ttt=average1[i];
average1[i]=average1[loc];
average1[loc]=ttt;
}  
        cout<<endl<<"Student ID "<<" "<<" midterm"<<midterm_score1[i]<<" "<<finaltest_score1[i]<<" "<<"Average"<<" "<<"Grade";
        for(int i=0;i<n1;i++)
        {
            cout<<endl<<id1[i];
            cout<<" "<<midterm_score1[i]<<" "<<finaltest_score1[i]<<" "<<average1[i]<<" "<<grade1[i];
       }
      
cout<<endl<<"Other classes";
        double average2[n2];
        char grade2[n2];

        for(int i=0;i<n2;i++)
        {
            average2[i]=0;
            for(int j=0;j<score_count[i];j++)
            {
                average2[i]+=scores2[j];
           }
           average2[i]/=score_count[i];
            if(average2[i]>=90)
                grade2[i]='A';
            else if(average2[i]>=80 && average2[i]<90)
                grade2[i]='B';
            else if(average1[i]>=70 && average2[i]<80)
                grade2[i]='C';
            else if(average2[i]>= &60& average2[i]<70)
                grade2[i]='D';  
   }
   //bubble sort
   int loc;
for (int i = 0; i < n2; ++i)
{

for (int j = i + 1; j < n2; ++j)
{
if (id[i] < id[j])
{
  
//Swap the values
  
}
}

  
}  
    //display
        exit(0);
}

}
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote