When I run write and run the program listed below, the output data screen disapp
ID: 3638018 • Letter: W
Question
When I run write and run the program listed below, the output data screen disappears pretty quickly (within the blink of an eye). I believe I am close to having the proper result, just need adjusted. Is it possible that you could assist me to make me aware of what the problem is with the code I came up with? Unsure where the compiler error is coming from, please help me.#include <iostream>
using namespace std;
class Employee
{
public:
int getID(void);
float getPayRate(void);
int getHours(void);
void setID(int);
void setPayRate(float);
void setHours(int);
void viewInfo(void);
private:
int ID;
float payRate;
int hours;
};
int Employee::getID()
{
return ID;
}
float Employee::getPayRate()
{
return payRate;
}
int Employee::getHours()
{
return hours;
}
void Employee::setID(int value)
{
ID = value;
}
void Employee::setPayRate(float value)
{
payRate = value;
}
void Employee::setHours(int value)
{
hours = value;
}
void Employee::viewInfo()
{
cout << ID << " " << payRate << " " << hours << endl;
}
int main() {
Employee array[100];
array[0].setID(666);
array[0].setPayRate(14.95);
array[0].setHours(40);
array[1].setID(246);
array[1].setPayRate(6.95);
array[1].setHours(37);
array[2].setID(75);
array[2].setPayRate(12.45);
array[2].setHours(80);
array[0].viewInfo();
array[1].viewInfo();
array[2].viewInfo();
return 0;
Explanation / Answer
If you are writing it on windows, your program works correctly, it just opend the console window and closes it after the program is done (which only takes a split of a second).
Put:
system("pause");
right above the "return 0;" line in your main function. This will keep the window open until you press any key.
Other than that, your program is fine:
666 14.95 40
246 6.95 37
75 12.45 80
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.