Topic List | Page List: 1 |
---|---|
Topic | C++ Help again. |
LookANinja 02/12/18 11:20:21 PM #1: | Write a program that - defines a class Employee with the following data members: - Name - Address - Title - Salary - Age - Department - defines a function that displays the information stored in an Employee object using the following format on 2 lines on the screen - Name (left,25), Address (left,25), Age (right,5) - Title (left,25), Department (left,25), Salary (right,10) - in main() - instantiate an object of type Employee - prompt the user for the information above (in the above order) and store it in the data members of the object instantiated - call the function to display the Employee information #include<iostream> #include<string> #include<iomanip> using namespace std; class Employee { public: string name; string address; string title; double salary; int age; string department; }; void DisInfo(Employee& emp1) { cout<<emp1.name<<emp1.address<<emp1.age<<endl; cout<<emp1.title<<emp1.department<<emp1.salary<<endl; } int main() { Employee emp1; cout<<"Please enter employee name"; getline(cin,emp1.name); cout<<"Please enter employee address"; getline(cin,emp1.address); cout<<"Please enter employee title"; getline(cin,emp1.title); cout<<"Please enter employee salary"; cin>>emp1.salary; cout<<"Please enter employee age"; cin>>emp1.age; cout<<"Please enter employee department"; getline(cin,emp1.department); void DisInfo(Employee& EmpInfo); } I think i'm close. (i know i gotta set the justification and stuff, but thats easy) --- ... Copied to Clipboard! |
Topic List | Page List: 1 |