Answer to Question #256703 in C++ for Dion Martins

Question #256703

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 nested for loop to determine the answer.


1
Expert's answer
2021-11-02T08:22:45-0400
#include <iostream>
using namespace std;
int main(){
    const int no_of_students = 100;
    char names[no_of_students][20];
    int test_mark1[no_of_students];
    int test_mark2[no_of_students];
    int test_mark3[no_of_students];
    int exam_mark[no_of_students];
    int final_mark[no_of_students];


    for(int i = 0; i < no_of_students; i++){
        cout<<"Enter name of student "<<i + 1<<endl;
        cin>>names[i];
        cout<<"Enter test mark 1: "<<endl;
        cin>>test_mark1[i];
        cout<<"Enter test mark 2: "<<endl;
        cin>>test_mark2[i];
        cout<<"Enter test mark 3: "<<endl;
        cin>>test_mark3[i];
        cout<<"Enter exam mark: "<<endl;
        cin>>exam_mark[i];


        final_mark[i] = 0.5 * exam_mark[i] + 0.5 * (test_mark1[i] + test_mark2[i] + test_mark3[i])/3;
    }


    cout<<"Name\tFinal Mark\t"<<endl;
    for(int i = 0; i < no_of_students;i++){
        cout<<names[i]<<"\t"<<final_mark[i]<<endl;
    }


    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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS