Results 1 to 16 of 16
  1. #1
    student2012 is offline Member
    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

    Default 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. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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. #3
    student2012 is offline Member
    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

    Default 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. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default 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. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

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

    What happens when you compile and run that?

  6. #6
    student2012 is offline Member
    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

    Default 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. #7
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

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

    Quote Originally Posted by student2012 View Post
    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?
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  8. #8
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

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

    Quote Originally Posted by student2012 View Post
    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?

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

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

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    Juukamen is offline Member
    Join Date
    Oct 2011
    Location
    Tromsų
    Posts
    54
    Rep Power
    0

    Default 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. #11
    kire9dk is offline Member
    Join Date
    Sep 2009
    Posts
    15
    Rep Power
    0

    Default 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. #12
    student2012 is offline Member
    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

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

    can someone pls show me how to construct that one?

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

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

    Quote Originally Posted by student2012 View Post
    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. #14
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

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

    Quote Originally Posted by student2012 View Post
    can someone pls show me how to construct that one?
    You still haven't posted the errors that you are receiving.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  15. #15
    student2012 is offline Member
    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

    Default 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. #16
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default 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
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. begginer needs help..?
    By lina in forum New To Java
    Replies: 4
    Last Post: 01-15-2010, 04:48 PM
  2. Any ideas on Program for begginer?
    By SwEeTAcTioN in forum New To Java
    Replies: 5
    Last Post: 11-02-2009, 01:45 AM
  3. Begginer and project
    By Gym in forum New To Java
    Replies: 6
    Last Post: 03-24-2009, 01:30 AM
  4. Student--begginer--help!!!
    By AmandaIT in forum New To Java
    Replies: 6
    Last Post: 05-09-2008, 03:37 AM
  5. Tic Tac Toe Ggame Help (Begginer)
    By zero2008 in forum New To Java
    Replies: 6
    Last Post: 01-11-2008, 10:18 PM

Posting Permissions

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