1.i)Create a class to hold all student attribute (name,reg number, course , gender and age) a read details method which interact with a user and read students details write details method to print write student details.
ii) create a main function which will prompt a user to enter student details call function read details and write details from a class above to read and write student detail respectively
#include<iostream>
using namespace std;
class Student{
private:
string name,reg_number, course , gender;
int age;
public:
void input(){
cout<<"Enter student's name:\n";
cin>>name;
cout<<"Enter student's registration number:\n";
cin>>reg_number;
cout<<"Enter student's course:\n";
cin>>course;
cout<<"Enter student's gender:\n";
cin>>gender;
cout<<"Enter student's age:\n";
cin>>age;
}
void output(){
cout<<"Name is: "<<name<<"\nRegistration Number is: "<<reg_number<<"\nCourse is: "<<course<<endl;
cout<<"Gender is: "<<gender<<"\nAge is: "<<age<<endl;
}
};
int main(){
Student st;
st.input();
st.output();
}
Comments
Leave a comment