The code below is for my assignment it works i just want to make sure i did this correct any advice is wanted. Also one thing that is bugging me see basepay well if the base pay is 133.20 it chops off the 0 and only displays 133.2 why iv tried all kinds of things ....
Thank you for your time!
//Ryan Summey
//Overtime Pay Structures
//04/20/2010
#include <iostream>
#include <string>
using namespace std;
struct Employee {
void DisplayEmployInformation();
string employeeName;
int hours, overtime_hours;
double wage, basepay;
double overtime_pay, overtime_extra;
double iIndividualSalary;
void otCalc(string EmployeeName, int hours, double wage);
};
int main()
{
Employee Employee0;
system("cls");
cout << "\nWelcome to the Employee Pay Center\n\n";
cout << "\n\nEnter the employee name = ";
cin >> Employee0.employeeName;
cout << "Enter the hours worked = ";
cin >> Employee0.hours;
cout << "Enter his or her hourly wage = ";
cin >> Employee0.wage;
Employee0.otCalc(Employee0.employeeName, Employee0.hours, Employee0.wage);
}
void Employee::otCalc(std::string EmployeeName, int hours, double wage){
basepay = 0.00;
overtime_hours = 0;
overtime_pay = 0.00;
overtime_extra = 0.00;
iIndividualSalary = 0.00;
if (hours > 40)
{
basepay = 40 * wage;
overtime_hours = hours - 40;
overtime_pay = wage * 1.5;
overtime_extra = overtime_hours * overtime_pay;
iIndividualSalary = overtime_extra + basepay;
DisplayEmployInformation ();
}
else{
basepay = hours * wage;
iIndividualSalary = basepay;
DisplayEmployInformation ();
}
}
void Employee::DisplayEmployInformation()
{
cout << "\n\n";
cout << "Employee Name ............. = " << employeeName << endl;
cout << "Base Pay .................. = " << basepay << endl;
cout << "Hours in Overtime ......... = " << overtime_hours << endl;
cout << "Overtime Pay Amout......... = " << overtime_extra << endl;
cout << "Total Pay ................. = " << iIndividualSalary << endl;
system("PAUSE");
return;
}