I am trying to make a program that takes an employees wage and their hours worked and have the output be their money made for that week. Anything over 40 hours is going to be counted for overtime at time and a half.
I can get the program to accuratley output the employees wage up to and including 40 hours but after that I will still only get the output of their wage at 40 hours; how can I get the accurate print out with their overtime hours counted?
As a side question this program only works for whole numbers, how can I get it to work with decimils, ex. 10.74, 12.10, 22.57, etc. as an hourly wage?
The current code is as followed:
int hoursWorked; //hours worked
int wage1; //hourly wage
int wage2; //time and a half pay
int overtime; //amount paid with overtime hours
std::cout << "Please enter your current wage: " ;
std::cin >> wage1 ; //input of current hourly wage
std::cout << "Please enter your hours worked this week: " ;
std::cin >> hoursWorked ; //input of hours worked
int regularPay; //amount made if worked 40hrs
int extraPay; //amount made if worked anything over 40hrs
regularPay = ( wage1 * 40 ) ;
extraPay = ( hoursWorked - 40 ) * wage2 ;
wage2 = wage1 + ( wage1 / 2 ) ;
overtime = regularPay + extraPay ; //overtime = amount made at 40hrs + amount made after 40hrs
/* If employee worked 40hrs or under then show the employees income at their regular wage;
and if employee works more than 40hrs show the employees income with their overtime included */
if ( hoursWorked <= 40 )
std::cout << "Your weekley income is " << wage1 * hoursWorked << '\n' ;
std::cout << "Your weekley income is " << overtime << '\n' ;