c++ program that accept employee


The distance between two cities is 500 miles. Let us call these cities as CityA and CityB. Employees live in the CityA and travel to the CityB every day in the morning and come back in the evening on the same day except on Saturday and Sunday. They do not travel on vacations, holidays and sick days. Make following assumptions:
On January 1st, it is Monday.

It is not a leap year and the total number of days in the year is 365.

Each employee has 6 days of holidays in a year.

Each employee is entitled for different number of vacation in a year. The managers are entitled for 20 days of vacation every year and the workers are entitled for 15 days.

The managers and the workers both are also entitled for different number of sick days in a year. For mangers this is 8 and for the workers it is 17.

Write a program which accepts the employee type from the user and based on that calculates many miles the employee will travel in a year. Test it for different types of employees. The majority of the codes should be written in separate function(s). Limit the code in the main function. The main function should be mostly calling the other functions to meet the requirement of the project.
Though the managers and the workers are entitled for certain number of vacations and sick leave, they don't have to use all of those in a year. They may decide to use only part of these. You program should ask the user the followings:
1. Type of employee.
2. Number of vacation days used.
3. Number of sick days used.
You should write validations to make sure that the number of vacation days used, and the number of sick days used do not exceed the number of days the employee is entitled to.

pls l need a start, how do i go about it
1
2
3
4
5
6
int main()
{


return 0;
}
Last edited on
thanks progrady
Well, ;)

What don't you understand? Specifically.
i appreciate your help. what l really dont understand is just where to start the code writing from ie what to compile and which to write.
Looks like ultimately the goal is to determine how many miles the employee will travel, and to output those miles.

You will probably have three functions: to determine employee type, to get the vacation time, and to determine the number of miles traveled.

You would call these functions from the main, using the main function as the coordinator between the three.
Last edited on
thanks alot, lm so grateful. l will try very well to write the code and post to check incase l couldnt build it.
l am so grateful, bless your heart. just started programming in my life and its so scary as this is my major and want to be good in it.

once again thank you. will write it asap
pls, help my code is not building,it is reading so many errors according to the question above. can someone look into it for me.


//Employee.h
#include <iostream>
#include <string>

using namespace std;
class employee;


private;
string type, cities, //string of type and different cities
int no of days of vacation used;
public
employee() // employee(const employee&)

{
type=0
cities-"";
number of vacation days used="";
number of sick days use="";
}
string getvacation(){
return vacation; //return pointer to the number of vacation days used,number of sick days used;

}
string setvacation(string v){
calculate miles travelled=m; //set miles to miles passed in parameter;
}

int getnumber of days of vacation used(){
return no of vacation days used; //return vacation from object
}
void setvacationdaysused (int v){;
if (v<0); // check if vacation is 0 or not;
number of vacation days used=0;
number of sick days used=0;
else;
number of vacation days used=0;
nuber of sick days used=0;
}

{
//main.cpp
#include <iostream>
#include <string>
class employee
using namespace std;

employee e1,e2,e3; // create 3 object for class employees
string gets(); //function defined to return a new string entered by user
void print(); //function to print the details of the 3 employees

int main(); //main start here;
int temp; //temp variables to hold miles travelled by the 3 employees

// 1st employee details entered by user
cout<<"\n enter the first city of 1st employee
e1.setcity(get());
cout<<"\n enter the no of days of vacation used;
e1.setnoofdaysofvacation used(get());
cout<<"\n enter the no of sick days used;
e1.setnoofsickdays used(get());
cin>>temp;
e1.setmiles travelled (temp);

//2nd employee details entered by user
cout<<"\n enter the first city of 1st employee
e2.setcity(get());
cout<<"\n enter the no of days of vacation used;
e2.setnoofdaysofvacation used(get());
cout<<"\n enter the no of sick days used;
e2.setnoofsickdays used(get());
cin>>temp;
e2.setmiles travelled (temp);

// 3rd employee details entered by user
cout<<"\n enter the first city of 1st employee
e3.setcity(get());
cout<<"\n enter the no of days of vacation used;
e3.setnoofdaysofvacation used(get());
cout<<"\n enter the no of sick days used;
e3.setnoofsickdays used(get());
cin>>temp;
e3.setmiles travelled (temp);

//output starts
cout << \n\n\n \t\t\t:: output start here::";
print(); call function to print details of the 3 employee;
cout<< calculate the miles travelled by the 3 employee
e1,set no of vacation days used (int) e1 get number of vaction days used()*20.8);
e2,set no of vacation days used (int) e2 get number of vaction days used()*15,17);
e3,set no of vacation days used (int) e3 get number of vaction days used()*20.8);

cout<<"\n\n\n \t\t\t::
print (); //again print details;
return 0; //finish main()

}
string get(){
string n;
cin>n;
return n;

}

@noranata Please refer a good c++ book before start writing code yourself.
This will help you and save your time as well.
Topic archived. No new replies allowed.