I'm trying to create the code for a paycheck program where I am paid double time for anything over 10 hours, time and a half for 8-10 hours and straight time for 0-8 hours. For some reason the pay isn't accumulating correctly. Any help would be appreciated.
#include <iostream>
using std::cout;
using std::cin;
#include <iomanip>
using std::endl;
int main()
{
double Array[13];
double pay = 0;
double payRate = 19.52;
for (int i = 0; i <= 12; i++)
Array[i] = 0;
for (int j = 1; j <= 12; j++)
{
cout << "Enter hours for day " << j << endl;
cin >> Array[j];
}
for (int k = 1; k <= 12; k++)
{
if (Array[ k ] > 10)
pay = ((payRate * 2 * (Array[ k ] - 10)) + (payRate * 1.5 * 2) + (payRate * 8));
else if (Array[ k ] > 8)
pay = ((payRate * 1.5 * (Array[ k ] - 8)) + ( payRate * 8));
else if (Array[ k ] >= 0)
pay = payRate * 8;
else cout << "Hours entered incorrectly, Please try again!\n" << endl;
pay += pay;
}
cout << pay;
return 0;
}