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
1
Expert's answer
2013-03-18T10:49:16-0400
/*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, 14: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, 19:36

Thank you very much

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS