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,
#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;
}
Comments
Leave a comment