help me to fix this program, please?

October 12, 2016 at 09:59:48
Specs: Windows 7
its a monthly payroll, although theres no error but my SSS, PHIC and PAGIBIG condition didnt read in mjy program
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;


// Prototype functions
double calcWage ();
double calcWage1 ();
double calcWage2 ();
double calcWage3 ();
double calcWage4 ();
void getEmployeeInfor();
void printWages();
void printTable();
void repeat();
void read();

// Defining terms for the program.

double PAGIBIG, SSS, PHIC, wages;
char name[12], position[12];
double rate, over, Hrate;
double wage, s, p, ph, totalmon, cmax, totalday;
int id;

//int id,result;
//double payRate, hours, wage;
ofstream outputFile;
ifstream inputFile;
string file,strings;
char repeatrAnswer;

int main()
{

cout << "Please enter the name of the file you wish to save to: ";
cin >> file;
outputFile.open(file.c_str());
// Get employee information
getEmployeeInfor();
// Calculate the total wage
wage = calcWage();
SSS = calcWage1();
PAGIBIG = calcWage2();
PHIC = calcWage3();
cmax = calcWage4();
// Prints the Table to the outputFile
printTable();
// Prints the wages to the output File
printWages();
// Ask if more informations wants to be added/ calculated
repeat();
// Call read function to read information to console
read ();

return 0;
}

// Function for asking user for Employee Id, pay rate, and the hours worked
void getEmployeeInfor()

{
cout <<"Enter Employee Name :";
cin >>name;
cout <<"Enter Employee ID :";
cin >>id;
cout <<"Position :";
cin >>position;
cout <<"Rate For Day :";
cin >>rate;
cout <<"No. Of Overtime(Hours) :\n";
cin >>over;
cout <<"Rate For Hours in Overtime :\n";
cin >>Hrate;

//Loop to check for valid numbers.
while ((id < 0) || rate < 0 || over < 0 || Hrate < 0)
{
cout << "Please enter valid values (Positive numbers): " << endl;
cout <<"Enter Employee ID :";
cin >>id;
cout <<"Rate For Day :";
cin >>rate;
cout <<"No. Of Overtime(Hours) :";
cin >>over;
cout <<"Rate For Hours in Overtime :";
cin >>Hrate;
}
}


// Function for calculating the Wage
double calcWage()
{

//double wages;
double totalday = rate * 22;
double cmax = totalday / 12;
double totalover = Hrate * over;
double income = totalday + totalover;
double benefit = SSS + PAGIBIG + PHIC;
return wage = income - benefit;

//double wages;
//return wages = payRate * hours;
}

double calcWage1()
{

//double wages;

if (totalday <= 10249.99&&totalday >= 9750.00)
{
SSS = 363.30;
}
else if (totalday <= 10749.99&&totalday >= 10250.00)
{
SSS = 381.50;
}
else if (totalday <= 11249.99&&totalday >= 10750.00)
{
SSS = 399.70;
}
else if (totalday <= 11749.99&&totalday >= 11250.00)
{
SSS = 417.80;
}
else if (totalday <= 12249.99&&totalday >= 11750.00)
{
SSS = 436.00;
}
else if (totalday <= 12749.99&&totalday >= 12250.00)
{
SSS = 454.20;
}
else if (totalday <= 13249.99&&totalday >= 12750.00)
{
SSS = 472.30;
}
else if (totalday <= 13749.99&&totalday >= 13250.00)
{
SSS = 490.50;
}
else if (totalday <= 14249.99&&totalday >= 13750.00)
{
SSS = 508.70;
}
else if (totalday <= 14749.99&&totalday >= 14250.00)
{
SSS = 526.80;
}
else if (totalday <= 15249.99&&totalday >= 14750.00)
{
SSS = 545.00;
}
else if (totalday <= 15749.99&&totalday >= 15250.00)
{
SSS = 563.20;
}
else if(totalday >= 15750.00)
{
SSS = 581.30;
}
return (SSS);

//double wages;
//return wages = payRate * hours;
}
double calcWage2()
{

//double wages;
if (totalday >= 1501.00)
{
PAGIBIG = 100.00;
}
return (PAGIBIG);

//double wages;
//return wages = payRate * hours;
}

double calcWage3()
{

//double wages;
if (totalday <= 7999.99&&totalday >= 7000.00)
{
PHIC = 87.50;
}
else if (totalday <= 8999.99&&totalday >= 8000.00)
{
PHIC = 100;
}
else if (totalday <= 9999.99&&totalday >= 9000.00)
{
PHIC = 112.50;
}
else if (totalday <= 10999.99&&totalday >= 10000.00)
{
PHIC = 125.00;
}
else if (totalday <= 11999.99&&totalday >= 11000.00)
{
PHIC = 137.50;
}
else if (totalday <= 12999.99&&totalday >= 12000.00)
{
PHIC = 150.00;
}
else if (totalday <= 13999.99&&totalday >= 13000.00)
{
PHIC = 162.50;
}
else if (totalday <= 14999.99&&totalday >= 14000.00)
{
PHIC = 175.00;
}
else if (totalday <= 15999.99&&totalday >= 15000.00)
{
PHIC = 187.50;
}
else if (totalday <= 16999.99&&totalday >= 16000.00)
{
PHIC = 200.00;
}
else if (totalday <= 17999.99&&totalday >= 17000.00)
{
PHIC = 212.50;
}
else if (totalday <= 18999.99&&totalday >= 18000.00)
{
PHIC = 225.00;
}
else if (totalday <= 19999.99&&totalday >= 19000.00)
{
PHIC = 237.50;
}
else if (totalday <= 20999.99&&totalday >= 20000.00)
{
PHIC = 250.00;
}
else if (totalday <= 21999.99&&totalday >= 21000.00)
{
PHIC = 262.50;
}
else if (totalday <= 22999.99&&totalday >= 22000.00)
{
PHIC = 275.00;
}
else if (totalday <= 23999.99&&totalday >= 23000.00)
{
PHIC = 287.50;
}
else if (totalday <= 24999.99&&totalday >= 24000.00)
{
PHIC = 300.00;
}
else if (totalday <= 25999.99&&totalday >= 25000.00)
{
PHIC = 312.50;
}
else if (totalday <= 26999.99&&totalday >= 26000.00)
{
PHIC = 325.00;
}
else if (totalday <= 27999.99&&totalday >= 27000.00)
{
PHIC = 337.50;
}
else if (totalday <= 28999.99&&totalday >= 28000.00)
{
PHIC = 350.00;
}
else if (totalday <= 29999.99&&totalday >= 29000.00)
{
PHIC = 362.50;
}
else if (totalday <= 30999.99&&totalday >= 30000.00)
{
PHIC = 375.00;
}
else if (totalday <= 31999.99&&totalday >= 31000.00)
{
PHIC = 387.50;
}
else if (totalday <= 32999.99&&totalday >= 32000.00)
{
PHIC = 400.00;
}
else if (totalday <= 33999.99&&totalday >= 33000.00)
{
PHIC = 412.50;
}
else if (totalday <= 34999.99&&totalday >= 34000.00)
{
PHIC = 425.00;
}
else if (totalday >= 35000.00)
{
PHIC = 437.50;}
return (PHIC);

//double wages;
//return wages = payRate * hours;
}
double calcWage4()
{

//double wages;
double totalday = rate * 22;
return cmax = totalday / 12;

//double wages;
//return wages = payRate * hours;
}


// Function for printing information to the outputFile
void printWages()
{
outputFile
<< setw(12) << name
<< setprecision(2) << fixed << setw (12)
<< id
<< setprecision(2) << fixed << setw (12)
<< rate
<< setprecision(2) << fixed << setw (12)
<< SSS
<< setprecision(2) << fixed << setw (12)
<< PAGIBIG
<< setprecision(2) << fixed << setw (12)
<< PHIC
<< setprecision(2) << fixed << setw (12)
<< over
<< setprecision(2) << fixed << setw (12)
<< Hrate
<< setprecision(2) << fixed << setw (12)
<< cmax
<< setprecision(2) << fixed << setw (12)
<< wage << endl;
}

// Function to print table to the outputFile
void printTable()

{
outputFile << setw(12) <<"Name"
<< setw(12) << "ID"
<< setw(12) << "Rate"
<< setw(12) << "SSS"
<< setw(12) << "Pag-IBIG"
<< setw(12) << "PHIC"
<< setw(12) << "OT"
<< setw(15) << "HrRate OT"
<< setw(12) << "13th MonPay"
<< setw(12) << "Wage"
<<endl;
outputFile << "------------------------------------------------------------------------------------------------------------------------\n";

}

// Function that asks the user if the process wants to be repeated
void repeat()
{
char answer;
cout << "Would you like to continue entering values? (y/n): ";
cin >> answer;
if (answer == 'y'|| answer == 'Y')
{

getEmployeeInfor(); // gets employee information
wage = calcWage(); // calculates wage
printWages(); // prints wage to the outputfile
// calls repeat function again;
repeat();
}
else
{
// Close the outputfile
outputFile.close();
cout << file << " was closed succesfully" << endl;
}
}

// Function that reads the data to the console
void read()
{
char repeatAnswer;
cout << "Would you like to read the file? (y/n): ";
cin >> repeatrAnswer;
if (repeatrAnswer == 'y' || repeatrAnswer == 'Y')
{
inputFile.open(file.c_str());
while (!inputFile.eof())
{
getline(inputFile, strings);
cout << strings<< endl;

}
cout << "Reading " << file << " completed." << endl;
repeat();
}

// Close inputFile
inputFile.close();
// Terminate the program
//exit(0);

}


See More: help me to fix this program, please?

Reply ↓  Report •

Related Solutions


Ask Question