# DECICION CONTROL STRUCTURES (begginer and i need help)

• 08-17-2012, 01:04 AM
student2012
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
• 08-17-2012, 01:18 AM
Fubarable
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.
• 08-17-2012, 01:55 AM
student2012
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);
}
}
• 08-17-2012, 01:59 AM
pbrockway2
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.
• 08-17-2012, 02:05 AM
pbrockway2
Re: DECICION CONTROL STRUCTURES (begginer and i need help)
What happens when you compile and run that?
• 08-17-2012, 02:06 AM
student2012
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.
• 08-17-2012, 02:08 AM
awinston
Re: DECICION CONTROL STRUCTURES (begginer and i need help)
Quote:

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?
• 08-17-2012, 03:46 AM
Junky
Re: DECICION CONTROL STRUCTURES (begginer and i need help)
Quote:

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?
• 08-17-2012, 07:50 AM
DarrylBurke
Re: DECICION CONTROL STRUCTURES (begginer and i need help)
• 08-17-2012, 04:13 PM
Juukamen
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
Code:

```if (condition) {     body-code } else {     else-code }```
Do you see what you were missing ?
• 08-17-2012, 06:12 PM
kire9dk
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.
• 08-18-2012, 02:30 AM
student2012
Re: DECICION CONTROL STRUCTURES (begginer and i need help)
can someone pls show me how to construct that one?
• 08-18-2012, 02:39 AM
pbrockway2
Re: DECICION CONTROL STRUCTURES (begginer and i need help)
Quote:

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.
• 08-18-2012, 02:45 AM
awinston
Re: DECICION CONTROL STRUCTURES (begginer and i need help)
Quote:

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.
• 08-18-2012, 03:18 AM
student2012
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
• 08-18-2012, 05:19 AM
DarrylBurke
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