Question

Currently, Marvel Academys student grade records are stored parallel arrays string names []Spider-Man, Iron Man,Black PNote: Please do this in C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

// Defining structure to store Student Grade records

struct Student {

string name;

int s1;

int s2;

int s3;

int s4;

float avg_grade;

};

//Defining function to compute average for a student

float average_grade(float a,float b,float c,float d){

float avg=(a+b+c+d)/4;

return avg;

}

//Defining function to display the details in array

void display(Student m[5])

{

cout << "Displaying array contents: "<< endl;

for (int i = 0; i < 5; i++)

{

cout << "Name: " << m[i].name << endl;

cout <<"Average: " <<fixed<<setprecision(2)<< m[i].avg_grade <<"\n"<<endl;

}

}

int main()

{

string names[]={"Spider_man","Iron_man","Black_panther","Dr.Strange","Thor"};

float exams[][4]={{98,96,93,88},{60,91,99,74},{95,85,94,88},{100,100,99,100},{58,83,76,60}};

Student* GradeList;

GradeList = new (nothrow) Student[5]; //created dynamic array of structures

for(int i=0;i<5;i++){ //floating the dynamic array with the students details

GradeList[i].name = names[i];

GradeList[i].s1=exams[i][0];

GradeList[i].s2=exams[i][1];

GradeList[i].s3=exams[i][2];

GradeList[i].s4=exams[i][3];

GradeList[i].avg_grade = average_grade(exams[i][0],exams[i][1],exams[i][2],exams[i][3]); //storing average

}  

display(GradeList);

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Note: Please do this in C++ Currently, Marvel Academy's student grade records are stored parallel arrays...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT