Answer to Question #241324 in C++ for Epiiii

Question #241324
Creath a Cluss teacher with data members

teacher number,

name,

Salary

and member functions to perform the following operations

a. Accept the details of a teacher

b. Display the details of a teacher
1
Expert's answer
2021-09-23T12:12:46-0400
#include <iostream>
#include <string>
using namespace std;


class Teacher{
private:
	int number;
	string name;
	double salary;
public:
	//Accept the details of a teacher
	void get(){
		cout<<"Enter a teacher number: ";
		cin>>number;
		cin.ignore();
		cout<<"Enter a teacher name: ";
		getline(cin,name);
		cout<<"Enter a teacher salary: ";
		cin>>salary;
	}
	//Display the details of a teacher
	void display(){
		cout<<"The teacher number: "<<number<<"\n";
		cout<<"The teacher name: "<<name<<"\n";
		cout<<"The teacher salary: "<<salary<<"\n";
	}
};




int main(){
	int N;
	Teacher Teacher;
	Teacher.get();
	Teacher.display();


	cin>>N;


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

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS