New to coding, need help with what to do next
Apr 10, 2013 at 5:27pm UTC
i'm fairly new to coding and i'm currently stuck on this one scenario i have to c'
Last edited on May 24, 2013 at 5:01pm UTC
Apr 10, 2013 at 6:00pm UTC
You need to check the number of employees. The max number of employees is 20, the minimum is 1 (you can't have zero, that means there is no company).
try this:
1 2 3 4 5
do
{
cout<<"Enter the amount of employees in your department:" <<endl;
cin>>numeploy;
}while (numeploy < 1 && numeploy > 20);
It also seems that you need an array of employees, with which the program should calculate the expenses from.
You can do it like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
enum ENGINE_TYPE
{
Diesel,
Class_A, //under 1400cc
Class_B //above 1400cc
};
struct Employee
{
std::string Name;
float Mileage;
ENGINE_TYPE Type;
void CalculateMileage();
void DisplayEmployeeSummary();
};
struct Department
{
~Department(){delete Employees;};
Employee* Employees;
std::string Name;
int NumberOfEmployees;
void DisplayDepartmentSummary();
};
The way the instructions are worded it seems that there can be multiple departments with multiple employees, and each needs to be displayed. By doing it like this all the display code is
encapsulated within the employee and department. Then all you need to do is create a department array within the main.
Last edited on Apr 10, 2013 at 6:15pm UTC
Topic archived. No new replies allowed.