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

Page 1 of 1

## 1 Replies - 301 Views - Last Post: 19 September 2012 - 01:22 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=292432&amp;s=04a036bac8ed72a7e7463dfb54563b15&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 hunter90

Reputation: 0
• 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

Reputation: 2
• 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.