Please help A small university has no more than 250 faculty members. A class cal
ID: 3830032 • Letter: P
Question
Please help A small university has no more than 250 faculty members. A class called faculty Type stores faculty data including first name, last name, department, salary, and number of years of service. The university uses a C++ main() program which stores faculty data in an array of faculty Type objects called Faculty. The university is able to perform the following actions: Add a new faculty member Increase all faculty members salary by a designated percent Output faculty information for all faculty who have more than 15 years of service Functions in main() are used to perform these actions Write the class definition of the class facultyType. It will have the usual print and setAll functions; add other set and get functions as needed. Write the function definitions of the facultyType class functions. Choose one of the main() program functions in the bulleted list above, and write it. (For the first bullet, assume that one of the parameters of your function is the index in the Faculty array where the new one is to be added). Indicate the function you choose here:___________Explanation / Answer
/*FacultyType.cpp I have Given An Menu Driven Program to Perform Different Operation Given In Problem Statement.*/
#include <iostream>
using namespace std;
class FacultyType
{
public:
/*Variable Declaration*/
string firstname,lastname,department;
double salary,percent;
int year;
/*Getters And Setters Method Used in The Program.*/
int getYear()
{
return year;
}
void setYear(int yr)
{
year=yr;
}
void setSalary(double per)
{
salary=salary+(salary*per/100);
}
void setAll(string first,string last,string dept,double sal,int yr)
{
firstname=first;
lastname=last;
department=dept;
salary=sal;
year=yr;
}
/*Method To print all The Data present at that object*/
void print()
{
cout<<" First Name :"<<firstname<<" Last Name :"<<lastname<<" Department :"<<department<<" Salary :"<<salary<<" Year :"<<year;
}
};/*End Of Class*/
int main()
{
FacultyType Faculty[250];/*Array of 50 faculty's(object)*/
string first,last,dept;
double sal,percent;
int yr,ch,inc=-1,i;
while(ch!=4)
{
cout<<" FACULTY MANAGEMENT SYSTEM ----------------------------- 1.Add a New Faculty Member. 2.Increase the Salary.";
cout<<" 3.Print faculty with more than 15 Year Exp. 4.Print All Faculty. 5.Exit";
cout<<" Enter Your Choice:";
cin>>ch;
switch(ch)
{
case 1:
inc++;/*it used to point to new object after incrementing it.*/
cout<<" Enter The FirstName :";
cin>>first;
cout<<" Enter The LastName :";
cin>>last;
cout<<" Enter The Department :";
cin>>dept;
cout<<" Enter Salary :";
cin>>sal;
cout<<" Enter Experience(in year) :";
cin>>yr;
Faculty[inc].setAll(first,last,dept,sal,yr);
cout<<" New Faculty Successfully Added.";
break;
case 2:
if(inc==-1)/*if there are 0 records in the Database*/
{
cout<<" No Records Present.";
}
else
{
cout<<" Enter The Percentage of Increase In salary :";
cin>>percent;/*Here I have Taken percentage from User*/
for(i=0;i<=inc;i++)
{
Faculty[i].setSalary(percent);
}
cout<<" Record Updated Successfully.";
}
break;
case 3:
if(inc==-1)/*if there are 0 records in the Database*/
{
cout<<" No Record Present.";
}
else
{
for(i=0;i<=inc;i++)
{
yr=Faculty[i].getYear();
if(yr>14)
{
Faculty[i].print();
}
}
}
break;
case 4:
if(inc==-1)/*if there are 0 records in the Database*/
{
cout<<" No Record Present.";
}
else
{
for(i=0;i<=inc;i++)
{
Faculty[i].print();
}
}
break;
case 5:
break;
default:
break;
}/*End Of Switch*/
}/*End Of While loop*/
return 0;
}/*End Of Main*/