When the hours worked is below 40, the result of the total pay will always be 0, Why? I tried rearranging the codes yet it still does the same thing. What am I doing wrong here?
#include <cstdio>
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
int skill, ins, hour, ret;
double rate;
cout << "Input Skill Level (1, 2, or 3)\n";
cin >> skill;
cout << "Input Hours Worked\n";
cin >> hour;
if (skill==1 &&hour<40) rate = 17;
else if (skill==2 && hour<40) rate = 20;
else if (skill==3 && hour<40) rate = 22;
else if (skill==1 && hour>40) rate = 25.5;
else if (skill==2 && hour>40) rate = 30;
else if (skill==3 && hour>40) rate = 33;
int pay = hour * rate;
int over = 0.5 * pay;
if (skill==1 &&hour<40) over = 0;
else if (skill==2 && hour<40) over = 0;
else if (skill==3 &&hour<40) over = 0;
int gross = pay + over;
switch (skill)
{
case 1:
{
if (hour>40)
{
cout << "You are Skill Level 1 and your regular pay is " <<pay << " and your overtime pay is "<< over<< " and your total pay is " << gross <<endl;
}
else if(hour<40)
{
cout << "You are Skill Level 1 and your regular pay is " <<gross << endl;
}
break;
}
case 2:
{
if (hour>40)
{
cout << "You are Skill Level 2 and your regular pay is " <<pay << " and your overtime pay is "<< over<< " and your total pay is " << gross <<endl;
}
else if(hour<40)
{
cout << "You are Skill Level 2 and your regular pay is " <<gross << endl;
}
break;
}
case 3:
{
if (hour>40)
{
cout << "You are Skill Level 3 and your regular pay is " <<pay << " and your overtime pay is "<< over<< " and your total pay is " << gross<< endl;
}
else if(hour<40)
{
cout << "You are Skill Level 3 and your regular pay is " <<gross << endl;
}
break;
}
default: cout << "Invalid Input" << endl; break;
}
if (skill==2 || skill==3) cout << "Select one of the following Insurance Options \n1 for Medical Insurance \n2 for Dental Insurance\n3 for Long-term Disability Insurance\n";
else cout << "Thank you for using our program\n";
cin >> ins;
switch(ins)
{
case 1: cout << gross - 32<< " is your final pay\n";break;
case 2: cout << gross - 20<< " is your final pay\n";break;
case 3: cout << gross - 10<< " is your final pay\n";break;
default: cout << "Invalid Input\n";
}
if (skill==3) cout << "Do you want to take our Retirement Plan? \n1 for Yes\n2 for No\n";
else cout << "Thank you for using out program\n";
cin >> ret;
if (ret==1) cout << "You have took our Retirement Plan and your Final Pay becomes "<< 0.97 * gross << endl;
else if (ret==2) cout << "You did not took our Retirement Plan and your Final Pay remains the same at " << gross << endl;
else cout << "Invalid Input\n";
cout << "Thank you for using our program, Hope you enjoy it and May You Have A Good Day!";
}