Write an algorithm that will accept the following for 100 students: The students’ name (studName) and 3 test marks (marks), as well as one exam mark (examMark). The program must calculate the final mark (finMark) for every student. The final mark comprises of 50% of the exam mark added to 50% of the average (agv) of the 3 tests. Display the final mark for every student.
1. Use a simple for-loop to determine the answer.
#include<iostream>
using namespace std;
int main(){
string studName[100];
double final_mark[100];
for(int i=0; i<100; i++){
cout<<"Enter student name: "<<endl;
cin>>studName[i];
double test1, test2, test3, exam;
cout<<"Enter test 1: "<<endl;
cin>>test1;
cout<<"Enter test 2: "<<endl;
cin>>test2;
cout<<"Enter test 3: "<<endl;
cin>>test3;
cout<<"Enter exam mark: "<<endl;
cin>>exam;
double average = (test1 + test2 + test3) /3;
final_mark[i] = average * 0.5 + exam * 0.5;
}
cout<<"Name\tFinal Mark"<<endl;
for(int i=0; i<100; i++){
cout<<studName[i]<<"\t\t"<<final_mark[i]<<endl;
}
}
Comments
Leave a comment