1 Replies - 218 Views - Last Post: 19 September 2012 - 01:22 AM Rate Topic: -----

#1 hunter90  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-September 12

how should i tackle this sode..which loop should i omplement

Posted 18 September 2012 - 11:37 PM

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
time-and-a-half for each additional hour as his gross pay.
His withholdings total 28.5% of his gross pay, meaning that
his net take-home 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.

Is This A Good Question/Topic? 0
  • +

Replies To: how should i tackle this sode..which loop should i omplement

#2 Serk102  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 9
  • Joined: 19-June 11

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.

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 take-home 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.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1