Answer to Question #268224 in C++ for Lameck abedi

Question #268224

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



1
Expert's answer
2021-11-18T15:21:41-0500
#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();
}

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS