At this particular time, I am taking comp science part 2. I am currently struggl
ID: 3638222 • Letter: A
Question
At this particular time, I am taking comp science part 2. I am currently struggling piecing together the final stages of the program listed below. It is asking me the "user" to show any and all employees, but those that have the default id of -1(negative one). I am looking for assistance on how to adjust the compiled information to make it work without any errors once outputted. Any help is greatly needed and welcomed...#include<iostream>
using namespace std;
class employee
{
private:
int id, maxHours;
float payRate;
public:
void setInfo (int pin, float pay, int hours)
{
id = pin;
payRate = pay;
maxHours = hours;
}
void viewInfo ()
// No parameters req.
{
cout<<"employee id: "<<id<<endl;
cout <<"employee pay rate: "<< payRate<<endl;
cout <<"employee max working hours"<<maxHours<<endl;
}
};
int main ( )
{
int pin, hours, record;
float pay;
int ch;
char ans;
employee empInfo[1000];
cout<<"1.ADD EMP 2.MODIFY EMP 3.DELETE EMP 4.EXIT";
cout<<"enter the choice: ";
cin>>ch;
switch(ch)
{
case 1:
cout <<"Enter employee 3 digit ID: ";
cin >> pin;
cout <<"Enter employee pay rate: ";
cin >> pay;
cout <<"Enter employee max hours: ";
cin >> hours;
empInfo[pin].setInfo(pin, pay, hours);
break;
case 2:
cout <<"Enter the employee ID# of the record you wish to modify ";
cin >> record;
empInfo[record].viewInfo();
break;
case 3:
cout <<"Enter the employee ID# of the record you wish to modify ";
cin >> record;
empInfo[pin].setInfo(0,0,0);
break;
case 4:
break;
}
return 0;
}
Explanation / Answer
#include using namespace std; class employee { private: int id, maxHours; float payRate; public: void setInfo (int pin, float pay, int hours) { id = pin; payRate = pay; maxHours = hours; } void viewInfo () // No parameters req. { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.