I am getting the error uninitialized local variable calculateTax used, I have attempted to define it with int and it didn't work, I am worried if I add something like int calculateTax = 0 it will override the function I have created for the variable.
I am a total noob when it comes to programming so I hope there is something obvious I am missing, any help would be most appreciated
Here is the code:
//Gross pay calculation
//additional tax rate calculation
#include <iostream>
#include <iomanip>
using namespace std;
//Setting global contants
const double PAY_RATE = 22.55;
const double BASE_HOURS = 40.0;
const double OT_MULTIPLIER = 1.5;
//Prototype functions
double getBasePay (double);
double getOvertimePay(double);
double getCalculateTax(double);
int taxRate;
int main()
{
double hours,
basePay,
overtime = 0.0,
taxRate,
taxOwed,
calculateTax,
totalPay;
//Input hours worked
cout << "How many hours did you work? ";
cin >> hours;
//Input Tax rate
cout << "What is the percent of your tax rate? ";
cin >> taxRate;
//get base pay
basePay = getBasePay(hours);
//Get OT if applicable
if (hours > BASE_HOURS)
overtime = getOvertimePay(hours);
//calculate total pay
totalPay = basePay + overtime;
//calculate Tax rate
taxOwed = calculateTax;
// Setting output format
cout << setprecision(2) << fixed << showpoint;
//Display calculated pay
cout << "Base pay: $" << basePay << endl
<< "Overtime pay: $" << overtime << endl
<< "Total pay: $" << totalPay << endl
<< "Taxes owed: $" << taxOwed << endl;
//Adding Pause before creating functions
char c;
cout << "Press any key to end program: ";
cin >> c;
return 0;
}
//#############################################
// Get base pay function accepts hours worked #
// and returns pay for non OT hours #
//#############################################
double getBasePay(double hoursWorked)
{
double basePay;
// determine base pay
if (hoursWorked > BASE_HOURS)
basePay = BASE_HOURS * PAY_RATE;
else
basePay = hoursWorked * PAY_RATE;
return basePay;
}
//##############################################
// The get overtime function accepts hours #
//then returns the OT pay if applicable #
//##############################################
double getOvertimePay(double hoursWorked)
{
double overtimePay;
//Determine OT pay
if (hoursWorked > BASE_HOURS)
{
overtimePay = (hoursWorked - BASE_HOURS) *
PAY_RATE * OT_MULTIPLIER;
}
else
overtimePay = 0.0;
return overtimePay;
}
//##########################################
//this taxes function calculates tax owed #
// based on the total pay regardless of OT #
//##########################################
double getCalculateTax(double totalPay)
{
double calculateTax;
calculateTax = (taxRate / 100) * totalPay;
return calculateTax;
}