WRITE A simple program will calculate the gross and net pay for
an employee, John Smith, who has worked 45½ hours this
week. He receives $12.00 an hour for the first 40 hours, and
timeandahalf for each additional hour as his gross pay.
His withholdings total 28.5% of his gross pay, meaning that
his net takehome pay is 71.5% of his gross pay.
The screen must display the employee’s name, total hours
worked, regular pay rate, total hours at regular pay rate, pay
rate at overtime, total hours at overtime, total gross pay,
withholdings, and net pay.
1 Replies  267 Views  Last Post: 19 September 2012  01:22 AM
#1
how should i tackle this sode..which loop should i omplement
Posted 18 September 2012  11:37 PM
Replies To: how should i tackle this sode..which loop should i omplement
#2
Re: how should i tackle this sode..which loop should i omplement
Posted 19 September 2012  01:22 AM
You really don't need a loop for this program at all, just some arithmetic.
Multiply the first two variables, and you get how much he made at 40 hours, then add the second two variables and you see how much he made at 45.5 hours.
Since John only gets to take home 71.5% of his gross pay though, we have to multiply his gross pay by that rate to get his net takehome pay. So...
Hope I could help, if you don't understand anything, please ask to me explain,as it's the concepts that are important, not the actual answer you get.
double hourlyWage = 12.00 //that's how much John makes an hour under working up to 40 hours double overtimeWage = 18.00 //that's how much he works when he goes over 40 hours double timeOnHourly = 40 //since John worked 45.5 hours, he only gets 40 hours on hourly wage double timeOnOvertime = 5.5 // the extra 5.5 hours gets overtime wage double grossPay = timeOnHourly*hourlyWage + timeOnOvertime*overtimeWage
Multiply the first two variables, and you get how much he made at 40 hours, then add the second two variables and you see how much he made at 45.5 hours.
Since John only gets to take home 71.5% of his gross pay though, we have to multiply his gross pay by that rate to get his net takehome pay. So...
double takeHomePay = grossPay*.715
Hope I could help, if you don't understand anything, please ask to me explain,as it's the concepts that are important, not the actual answer you get.
Page 1 of 1
