64 638
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #24333 in C++ for Miguel Abanilla

Question #24333
Write a C++ program that will enter the Name, Age, and Gender of a student. Test the Gender and Age. If Age is greater than or equal to 18, display the Name, followed by the remarks. "The student is a (male/female) voter", otherwise, display, "The student is a (male/female) non-voter".
Expert's answer
# include <iostream>
# include <string >
using namespace std;

class stud{
private:
string name;
int age;
bool gen;//1-boy
public:
void in(){
cout<<"Name:";
getline(cin,name,'\n');
cout<<"age:";
cin>>age;
cout<<"Gender: 1- male, 0- female";
cin>>gen;
}
void print(){
if ( gen==1){
cout<<"The student is a male ";
if (age>=18) cout<<"voter\n";
else cout<<"non-voter\n";

}
else
{cout<<"The student is a female ";
if (age>=18) cout<<"voter\n";
else cout<<"non-voter\n";
}
}


};
int main(){
setlocale( LC_ALL,"Russian" );
stud a;
a.in();
a.print();

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

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions