Answer to Question #275107 in C++ for Thabo

Question #275107

Write a C++ program that will allow the teachers to do the following:

4.1 Capture the student performance record in a sentinel-controlled loop and store the results in three parallel arrays. The information to be stored in the three arrays is the student’s full name, continuous assessment mark, and final mark. If the lecturer types the word ‘Done’ instead of a full name, the loop should immediately stop even before capturing any marks.

(6 Marks)

4.2 Search the array for the student’s full name and then display the full record of the student, or the notification that student does not exist. You should also allow the teachers to search for the best or worst performer in the Final Mark column. When the mark is found, let it be displayed with all the student’s details. (8 Marks)

4.3 Make this program a menu driven system with the following options: Capture Marks, Find a Student, Find the Best Performer, Find the Worst Performer,


1
Expert's answer
2021-12-03T14:34:38-0500
#include <iostream>

using namespace std;

#define N 1024

string name[N];
int con_mark[N];
int fin_mark[N];

int i=0;

void store(){
  cout<<"Full name:";
  cin>>name[i];
  cout<<"Continuous mark:";
  cin>>con_mark[i];
  cout<<"Final mark:";
  cin>>fin_mark[i];
}

int find(string s){
 int idx=-1;
 for(int j=0;j<i;j++)
  if(s==name[j])idx=j;
 return idx;
}

int main(){
 string s;
 while (1) {
  cout<<"[1] Store"<<endl
      <<"[2] Find"<<endl
      <<"[0] Done"<<endl;
  cin>>s;
  if(s=="1"){
    store();
    i++;
  }
  if(s=="2"){
    cin>>s;
    int idx=find(s);
    if(idx==-1)
     cout<<"Not found"<<endl;
    else
     cout<<name[idx]<<endl
         <<con_mark[idx]<<endl
         <<fin_mark[idx]<<endl;
  }
  if(s=="0")break;
 }
 return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment