#include
using namespace std;
class StudentProfile {
private: //Acess specifier
string name = ""; //private information
string major = ""; //private information
string term = ""; //private information
double termAverage = 0;
public: //Acess specifier
StudentProfile(string namen, string majorm, string termn, int terma){
this ->name = namen;
this ->major = majorm;
this ->term = termn;
this ->termAverage = terma;
}
int scores[5]= {85,87,97,86,95}; //Member function
double findAverage(){//Member function
double Average = this ->scores[0] + this ->scores[1] + this ->scores[2] + this ->scores[3] + this ->scores[4];
Average = Average/5;
this ->termAverage = Average;
return Average;
}
void displayProfile(){ //Member Function
cout termAverage;
}
void setScore(int index, int scoreln){
this ->scores[index] = scoreln;
}
};
int main(){
StudentProfile StudentRecord("","","",90);//creates an object of StudentProfile
int courseOne = 80;
StudentRecord.setScore(0, courseOne);
int courseTwo = 70;
StudentRecord.setScore(1, courseTwo);
int courseThree = 70;
StudentRecord.setScore(2, courseThree);
int courseFour = 70;
StudentRecord.setScore(3, courseFour);
int courseFive = 70;
StudentRecord.setScore(4, courseFive);
dProfile.findAverage();
dProfile.displayProfile();
return 0;
}
Мне трудно вводить пользовательский ввод для имени, основных, терминов и среднего значения. Мне также трудно вносить вклад в 5 курсов. < /p> [code]#include using namespace std;
class StudentProfile { private: //Acess specifier string name = ""; //private information string major = ""; //private information string term = ""; //private information double termAverage = 0;
public: //Acess specifier
StudentProfile(string namen, string majorm, string termn, int terma){
this ->name = namen; this ->major = majorm; this ->term = termn; this ->termAverage = terma; }
int scores[5]= {85,87,97,86,95}; //Member function
double findAverage(){//Member function double Average = this ->scores[0] + this ->scores[1] + this ->scores[2] + this ->scores[3] + this ->scores[4]; Average = Average/5; this ->termAverage = Average; return Average; }
void displayProfile(){ //Member Function cout termAverage; } void setScore(int index, int scoreln){ this ->scores[index] = scoreln; } };
int main(){
StudentProfile StudentRecord("","","",90);//creates an object of StudentProfile
int courseOne = 80; StudentRecord.setScore(0, courseOne);
int courseTwo = 70; StudentRecord.setScore(1, courseTwo);
int courseThree = 70; StudentRecord.setScore(2, courseThree);
int courseFour = 70; StudentRecord.setScore(3, courseFour);
int courseFive = 70; StudentRecord.setScore(4, courseFive);