Patrick B. answered 08/23/21
Math and computer tutor/teacher
using namespace std;
#include <iostream>
#include <string>
class Student
{
private:
string name;
int age;
char gender;
public:
Student (string nameStr, int x,char chGender )
{
this->SetName(nameStr);
this->SetAge(x);
this->SetGender(chGender):
}
void GetName(string & strName) { strName=name; }
int GetAge() { return (age);}
char GetGender() { return gender;}
void SetName( string nameStr){ name=nameStr;}
void SetAge( int x) { age=x;}
void SetGenderMale() { gender=0;}
void SetGenderFemale() { gender=1;}
}
int GetYear(int x) { return (x+5);}
main()
{
string nameStr;
int x;
int iGender;
char chGender;
cout《 "Please input student name :>";
cin》nameStr;
cout《 "Please input student age :>";
cin》x;
iGender=-1;
while (iGender<0 || iGender>1)
{
cout《 "Please input 0 for male 1 for female:>";
cin》iGender;
}
chGender= (iGender==1)? 1:0;
Student s1(nameStr,x,chGender);
cout《 "student name:"《s1.GetName()《endl;
int iAge=s1.GetName();
cout《 "student age:"《 iAge《endl;
cout《 " graduation age in 5 years"《 GetYear() 《endl;
chGender= s1.GetGender();
If (chGender==1) { cout 《 "female ";}
else { cout 《"male";}
}