66 840
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #26661 in C++ for meme

Question #26661
Write C++ Console Application to calculate and display the average CGPA of 10 students with the following requirements.
1.Your program must use Class for student which have the following variables/attributes
1.Name
2.MatrixNo
3.Cgpa.
2.Your program should get information of 10 students Name,MatrixNo,Cgpa) from User and store it in Arrayof object of type Student (from item 1).
3.Then, your program must calculate and display the average CGPA from the Array(from item 2
Expert's answer
/*Write C++ Console Application to calculate and display the average CGPA of
10 students with the following requirements.
1.Your program must use Class for student which have the following
variables/attributes
1.Name
2.MatrixNo
3.Cgpa.
2.Your program should get information of 10 students Name,MatrixNo,Cgpa)
from User and store it in Arrayof object of type Student (from item 1).
3.Then, your program must calculate and display the average CGPA from the
Array(from item 2*/
# include <iostream>
# include < string>
using namespace std;
class stud{
protected:
string name;
string mat;
double gpa;
public:
void get(){
cout<<"Name:";
getline(cin,name,'\n');

cout<<"matrix number:";
/*cin.ignore();*/
getline(cin,mat,'\n');

cout<<"GPA:";
cin>>gpa;
cout<<endl;
cin.ignore();
}
friend double average(stud a[], int len);
};
double average(stud a[], int len){
double av=0;
for (int i=0; i<len;i++){
av+=a[i].gpa;
}
return av/len;
}
int main(){
stud s[10];
for (int i=0; i<10;i++){
s[i].get();
}
cout<<"average GPA:"<<average(s,10);

system("PAUSE");
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

Assignment Expert
22.03.13, 15:08

You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

meme
18.03.13, 20:36

Thank you very much

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions