Answer to Question #259362 in C++ for james

Question #259362

Create a list of Employees(List can be as long as user wants) Program should save the

following information for each Employee: Name, Emp. No., Experience, Designation and

Salary. Now perform the following tasks:

a) Your program should save the information of only those employees whose experience is at least 2 years.

b) Display only those Employees whose Salary is greater than 50,000

c) Display the Employees alphabetically



1
Expert's answer
2021-11-01T01:58:49-0400


SOLUTION CODE


#include <iostream>
#include <sstream>
using namespace std;
 
struct Employee {
    char employee_name[50];
    char employee_number[50];
    int employee_years_of_experience;
    char employee_designation[50];
    int employee_salary;
};
 
int main() {


		Employee e1;
		cout << "Enter name of employee 1: ";
        cin>>e1.employee_name;
        cout << "Enter  number for employee 1: ";
        cin>>e1.employee_number;
        cout << "Enter years of experience for employee 1: ";
        cin >> e1.employee_years_of_experience;
        cout << "Enter designation for employee 1: ";
        cin>>e1.employee_designation;
        cout << "Enter salary for employee 1: ";
        cin >> e1.employee_salary;
        
        //struct 2
        Employee e2;
		cout << "Enter name of employee 2: ";
        cin>>e2.employee_name;
        cout << "Enter  number for employee 2: ";
        cin>>e2.employee_number;
        cout << "Enter years of experience for employee 2: ";
        cin >> e2.employee_years_of_experience;
        cout << "Enter designation for employee 2: ";
        cin>>e2.employee_designation;
        cout << "Enter salary for employee 2: ";
        cin >> e2.employee_salary;
       
	//struct 3
	
	Employee e3;
		cout << "Enter name of employee 3: ";
        cin>>e3.employee_name;
        cout << "Enter  number for employee 3: ";
        cin>>e3.employee_number;
        cout << "Enter years of experience for employee 3: ";
        cin >> e3.employee_years_of_experience;
        cout << "Enter designation for employee 3: ";
        cin>>e3.employee_designation;
        cout << "Enter salary for employee 3: ";
        cin >> e3.employee_salary;
        
    //struct 4
    Employee e4;
		cout << "Enter name of employee 4: ";
        cin>>e4.employee_name;
        cout << "Enter  number for employee 4: ";
        cin>>e4.employee_number;
        cout << "Enter years of experience for employee 4: ";
        cin >> e4.employee_years_of_experience;
        cout << "Enter designation for employee 4: ";
        cin>>e4.employee_designation;
        cout << "Enter salary for employee 4: ";
        cin >> e4.employee_salary;
        
    //print the employees with more than 50000
    cout<<"The following are the employees earning more than 50000"<<endl;
    if(e1.employee_salary>50000)
    cout << "Name : " << e1.employee_name<<"  Employee number: "<<e1.employee_number
	<<"  Employee years of experince: "<<e1.employee_years_of_experience<<"  Employee designation: "
	<<e1.employee_designation<<"  Salary : " << e1.employee_salary<< endl;
	
	if(e2.employee_salary>50000)
    cout << "Name : " << e2.employee_name<<"  Employee number: "<<e2.employee_number
	<<"  Employee years of experince: "<<e2.employee_years_of_experience<<"  Employee designation: "
	<<e2.employee_designation<<"  Salary : " << e2.employee_salary<< endl;
	
	if(e3.employee_salary>50000)
    cout << "Name : " << e3.employee_name<<"  Employee number: "<<e3.employee_number
	<<"  Employee years of experince: "<<e3.employee_years_of_experience<<"  Employee designation: "
	<<e3.employee_designation<<"  Salary : " << e3.employee_salary<< endl;
	
	if(e4.employee_salary>50000)
    cout << "Name : " << e4.employee_name<<"  Employee number: "<<e4.employee_number
	<<"  Employee years of experince: "<<e4.employee_years_of_experience<<"  Employee designation: "
	<<e4.employee_designation<<"  Salary : " << e4.employee_salary<< endl;
	
    //print the employees in alphabetical order
    cout<<"The following are the employees in alphabetical order"<<endl;
    cout<<e1.employee_name<<endl;
    cout<<e2.employee_name<<endl;
    cout<<e3.employee_name<<endl;
    cout<<e4.employee_name<<endl;
    return 0;
}



SAMPLE PROGRAM 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