# Thread: DECICION CONTROL STRUCTURES (begginer and i need help)

1. Member
Join Date
Aug 2012
Posts
5
Rep Power
0

## DECICION CONTROL STRUCTURES (begginer and i need help)

If/else structure i need help?
using an if/else construct, white a program that will calculate a person's pay based on the number of hours work.

1.
= The pay rate is php 35.00 per hour. Any hours worked after 40 hours is paid at the rate of 1.5 times the normal hourly rate. Calculate and display the normal pay, the overtime pay and the total pay.
=you may test your program using the following test data for the number of hours worked:
35
40
50

2. modify WorkPay.java by replacing the if/else construct with the swtich statement. Follow the same specifications as indicated above expect for the file name. Name this program as WorkPay2.java

you may test your program using the following test data for the number of hours worked:
30
35
40
45
50

2. ## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

What confuses you exactly? The more effort you put into writing out a well thought out question, the better we will understand what your problem is and the better we'll be able to help you.

3. Member
Join Date
Aug 2012
Posts
5
Rep Power
0

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

this is what i did but it got error so idk whats wrong at all

import java.util.Scanner;
class WorkPay
{

public static void main(String[] args) {

//declare the variables
double hour = 0.00;
double pay = 0.00;
Scanner scanner = new Scanner(System.in);
System.out.println("\nEnter the number hours worked");
hour = scanner.nextDouble();
if (hour <= 40.00)
pay = hour * 35.00;
else
pay = ((hour - 40)*1.5*35.00) + (40*35.00);
System.out.println("\nYour pay for "+hour+" hours is " + pay);
}
}

4. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,565
Rep Power
12

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

Figure out a general plan: what are you going to ask the user? What are you going to do with their responses?

Write code and see what happens. You don't have to figure the while thing out at once. It really helps people to see even partial code and if you say what is going wrong - compiler messages etc.

5. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,565
Rep Power
12

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

What happens when you compile and run that?

6. Member
Join Date
Aug 2012
Posts
5
Rep Power
0

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

it got 5 errors and idk what to do with it or how to fix it.

7. Student
Join Date
Jul 2012
Location
United States
Posts
328
Rep Power
2

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

Originally Posted by student2012
it got 5 errors and idk what to do with it or how to fix it.
Can you please post the error messages for us?

8. ## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

Originally Posted by student2012
it got 5 errors and idk what to do with it or how to fix it.
My car won't start, can you fix it?

10. Member
Join Date
Oct 2011
Location
Tromsų
Posts
42
Rep Power
0

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

Yo mate, you're doing some errors here.
Look on this and fix up your program
Java Code:
```if (condition) {
body-code
} else {
else-code
}```
Do you see what you were missing ?

11. Member
Join Date
Sep 2009
Posts
15
Rep Power
0

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

I have 1 question, what are u entering into the console ?
If you enter text or not number, you will have error :).

Tell more details what happens and when.

12. Member
Join Date
Aug 2012
Posts
5
Rep Power
0

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

can someone pls show me how to construct that one?

13. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,565
Rep Power
12

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

Originally Posted by student2012
can someone pls show me how to construct that one?
Mostly people will not post solutions, as that doesn't help.

-----

The way forward is to say what was entered when you ran the program (#11). And also what the errors were (#7). It might also help if you posted the commands you are using to compile and run the program.

14. Student
Join Date
Jul 2012
Location
United States
Posts
328
Rep Power
2

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

Originally Posted by student2012
can someone pls show me how to construct that one?
You still haven't posted the errors that you are receiving.

15. Member
Join Date
Aug 2012
Posts
5
Rep Power
0

## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

this is the output i should get
ImageShack® - Online Photo and Video Hosting

but the structure that i make is different below is my structure theres no error on it, so the output that showin is like this below my if/else structure:

import java.util.Scanner;
class WorkPay
{

public static void main(String[] args) {

//declare the variables
double hour = 0.00;
double pay = 0.00;
Scanner scanner = new Scanner(System.in);
System.out.println("\nEnter the number hours worked");
hour = scanner.nextDouble();
if (hour <= 40.00)
pay = hour * 35.00;
else
pay = ((hour - 40)*1.5*35.00) + (40*35.00);
System.out.println("\nYour pay for "+hour+" hours is " + pay);
}
}

OUTPUT:
PROCESS COMPLETE

--------------------Configuration: <Default>--------------------

Enter the number hours worked

16. ## Re: DECICION CONTROL STRUCTURES (begginer and i need help)

Evidently you didn't bother to go through any of the links I posted at response #9. Please don't post again until you do.

db

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•