3,085 questions
// Define variables
double hourlyWage = 15.50;
int hoursWorked = 40;
double overtimeRate = 1.5;
int overtimeThreshold = 40;
double salary = 0;
// Calculate salary
if (hoursWorked <= overtimeThreshold)
{
salary = hourlyWage * hoursWorked;
}
else
{
int overtimeHours = hoursWorked - overtimeThreshold;
salary = (hourlyWage * overtimeThreshold) + (overtimeHours * overtimeRate * hourlyWage);
}
hope this helps