#include <iostream>
#include <iomanip>
#include <ctime>
#include <fstream>
using namespace std;
int main()
{
// Reads input from file
fstream file;
file.open("program3input.txt");
// Define Constants
const double FICAPERCENTAGE = 0.0765;
const double FEDERALTAX = 0.1500;
const double INCOMETAX = 0.0300;
// Define Variables
int employeeNumber;
double hourlyRate;
int hoursWorked;
double normalPay;
double overtime;
double overtimePay;
// Dispays time and date function
time_t sysTime;
time (&sysTime);
//Calculate gross and net pay
double grossPay = static_cast<double>(hoursWorked) * hourlyRate + overtimePay * overtime;
double overtime = hoursWorked - 40;
double overtimePay = (hoursWorked - 40)* (normalPay * 1.5)+ (40 * normalPay);
double ficaDeduction = grossPay * FICAPERCENTAGE;
double federalTax = grossPay * FEDERALTAX;
double incomeTax = grossPay * INCOMETAX;
double netPay = grossPay - ficaDeduction - federalTax - incomeTax;
double totalDeduction = ficaDeduction + federalTax + incomeTax;
/*Print employee number, hourly rate, hours worked, total gross pay, FICA
and Federal deduction, along with Net pay */
fout.open ("program3output.txt");
cout << fixed << setprecision(2); // Sets output at 2 decimal places
cout << endl;
fout << fixed << setprecision(2); // Sets output at 2 decimal places
fout << endl;
cout << "Joe's Hardware Payroll Program" << setw(5) << endl;
fout << "Joe's Hardware Payroll Program" << setw(5) << endl;
cout << "The current local date/time: " <<ctime(&sysTime);
fout << "The current local date/time: " <<ctime(&sysTime);
cout << "---------------------------------------------------------" << endl;
fout << "---------------------------------------------------------" << endl;
cout << "Employee Number: " << setw(10) << employeeNumber << endl << endl;
fout << "Employee Number: " << setw(10) << employeeNumber << endl << endl;
cout << "Hourly rate of pay: $ " << setw(6) << hourlyRate << endl;
fout << "Hourly rate of pay: $ " << setw(6) << hourlyRate << endl;
cout << "Regular Hours worked: " << setw(10) << hoursWorked << endl;
fout << "Regular Hours worked: " << setw(10) << hoursWorked << endl;
cout << "Overtime Hours Worked: " << setw(10) << overtime << endl;
fout << "Overtime Hours Worked: " << setw(10) << overtime << endl;
cout << "Total Gross Pay: $ " << setw(4) << grossPay << endl;
fout << "Total Gross Pay: $ " << setw(4) << grossPay << endl;
cout << "Deductions: " << setw(14) << endl;
fout << "Deductions: " << setw(14) << endl;
cout << "FICA: $ " << setw(8) << ficaDeduction << endl;
fout << "FICA: $ " << setw(8) << ficaDeduction << endl;
cout << "Federal Tax: $ " << setw(8) << federalTax << endl;
fout << "Federal Tax: $ " << setw(8) << federalTax << endl;
cout << "---------------------------------------------------------" << endl;
fout << "---------------------------------------------------------" << endl;
cout << "Total Deductions: $ " << setw(8) << totalDeduction << endl;
fout << "Total Deductions: $ " << setw(8) << totalDeduction << endl;
cout << " ======" << endl;
fout << " ======" << endl;
cout << "Net Pay: $ " << setw(6) << netPay << endl;
fout << "Net Pay: $ " << setw(6) << netPay << endl;
cout << "---------------------------------------------------------" << endl;
fout << "---------------------------------------------------------" << endl;
return 0;
}
My errors
1>------ Build started: Project: Program3, Configuration: Debug Win32 ------
1>Build started 10/6/2012 4:16:39 PM.
1>InitializeBuildStatus:
1> Touching "Debug\Program3.unsuccessfulbuild".
1>ClCompile:
1> Program3.cpp
1>f:\program3\program3\program3.cpp(46): error C2086: 'double overtime' : redefinition
1> f:\program3\program3\program3.cpp(35) : see declaration of 'overtime'
1>f:\program3\program3\program3.cpp(47): error C2086: 'double overtimePay' : redefinition
1> f:\program3\program3\program3.cpp(36) : see declaration of 'overtimePay'
1>f:\program3\program3\program3.cpp(57): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(57): error C2228: left of '.open' must have class/struct/union
1> type is ''unknown-type''
1>f:\program3\program3\program3.cpp(60): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(61): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(61): error C2563: mismatch in formal parameter list
1>f:\program3\program3\program3.cpp(61): error C2568: '<<' : unable to resolve function overload
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(1021): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=unsigned short,
1> _Traits=std::char_traits<unsigned short>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(1011): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(1003): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(977): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>f:\program3\program3\program3.cpp(63): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(65): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(67): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(69): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(71): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(73): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(75): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(77): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(79): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(81): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(83): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(85): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(87): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(89): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(91): error C2065: 'fout' : undeclared identifier
1>f:\program3\program3\program3.cpp(93): error C2065: 'fout' : undeclared identifier
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.02
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

New Topic/Question
Reply



MultiQuote







|