# Include <iostream. h>
# Include "string. H"
Class score
{
PRIVATE:
Char name [8], XH [7];
Double Sx, YW, YY;
Public:
Score (char N [8], char Z [7], double A, double B, double C)
{
Strcpy (name, N );
Strcpy (XH, Z );
SX =;
YW = B;
YY = C;
}
Score ()
{
Cout <"Enter name :";
Cin> name;
Cout <"Enter the student ID :";
Cin> XH;
Cout <"Enter the math score :";
Cin> SX;
Cout <"enter Chinese score :";
Cin> YW;
Cout <"Enter the English score :";
Cin> YY;
}
Void display ()
{
Cout <"output name :";
Cout <name <Endl;
Cout <"output student ID :";
Cout <XH <Endl;
Cout <"total score of three subjects :";
Cout <SX + YW + YY <Endl;
Cout <"average output score :";
}
Friend double average (score );
};
Double average (score X)
{
Double PJ;
PJ = (X. SX + X. YW + X. yy)/3;
Return PJ;
}
Void main ()
{
Score S;
S. Display ();
Cout <average (s) <Endl;
}
Question requirements: design a score for a student, which includes a student ID, name, mathematics, Chinese, English, and average score. Then define a general function average () for calculating the average score of a student (), this function is also defined as a friend function of the score class. In the main letter, it defines the Student Score object, assigns values to members other than the initial average score through the constructor, and then calls average (), calculate the average score and assign values to all the student scores!