Friday, 28 March 2014

o Write a program which demonstrates overloaded functions to calculate the gross weekly pay of hourly-paid or salaried employees. Note(one overloaded function return the gross weekly pay of hourly-wage employee and other overloaded function calculate and return the gross weekly pay of salaried employ)

#include <iostream>
 using namespace std;
int salary(int , int);
int salary(int );

void main()
{
int ratePerHour, totalHours, yearSalary;
cout << "Enter Rate per Hour : ";
cin >>ratePerHour;
//Part 1
cout <<endl << "Enter Total number of Hours per Day : ";
cin >> totalHours;
cout <<endl << "Weekly Salary of hourly-wage employee Is : "<<salary(ratePerHour,totalHours) <<endl <<endl;

//part 2
cout << "Enter Whole year Salary of salaried employee : " ;
cin >> yearSalary;
cout <<endl << "Weekly Salary of salaried employee Is : " <<salary(yearSalary);

int z;
cin>>z;
}
int salary(int h, int r)
{
return (h*r)*7;

}
int salary(int s)
{
int sal;
sal = s /12 ; //to get per month salary
sal = sal /4 ;  //to get per week salay
return sal ;
}

No comments:

Post a Comment