Results 1 to 6 of 6
  1. #1
    afrttoh is offline Member
    Join Date
    Nov 2008
    Location
    London
    Posts
    39
    Rep Power
    0

    Default I couldn’t figure out how to do this please help!

    Java Code:
    import javax.swing.JOptionPane;
    public class PayCheckWeek7
    {
    	public static void main(String[] args)
    	{
    		String input = JOptionPane.showInputDialog("What's your name?");
    		String input1 = JOptionPane.showInputDialog("What's your hourly wage?");
    		double n = Double.parseDouble(input1);
    		String input2 = JOptionPane.showInputDialog("how many hours you worked in the past week?");
    		double m = Double.parseDouble(input2);
    	   	
    		if (m > 40)
    		{
    			JOptionPane.showMessageDialog (null,"your wage this week is: " + ((n*m)*1.5));
    		}
    
    		else
    		{
    			JOptionPane.showMessageDialog (null,"your wage this week is: " + (n*m));
    		}
    		
    		     
    		
    	}
    }


    I need to modify the above program. The functionality of the new program should be exactly the same. However, write a method called
    calculatePay, which calculates the total amount of pay. Call this method
    from within the main method, and display its return value.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Let's see a decent try by you towards a solution first. I've found that usually the more thought and effort posters put into creating and solving their questions, the better their chances are of a volunteer here taking the time and effort to consider it and give a helpful answer. Much luck.

  3. #3
    afrttoh is offline Member
    Join Date
    Nov 2008
    Location
    London
    Posts
    39
    Rep Power
    0

    Default ok!

    Quote Originally Posted by Fubarable View Post
    Let's see a decent try by you towards a solution first. I've found that usually the more thought and effort posters put into creating and solving their questions, the better their chances are of a volunteer here taking the time and effort to consider it and give a helpful answer. Much luck.
    Thanks, but I think if you can’t help you should just watch , there is no need of what you have said <wrote> because you are in the wrong place i guess.
    i am not a lazy person who needs some one to write codes for him i just needs some help and guide lines.

    I have written this program from scratch and i am just finding it hard to do the 2nd part of the exercise which I have explained above...

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Please lighten up. Know that we are all volunteers here and I would think that any suggestion that could help you get more help would be appreciated. It's up to you.

    Regardless please answer this question: how will anyone here know what precisely you are confused with if we don't first see your attempt and how exactly it is not working?
    Last edited by Fubarable; 11-19-2008 at 08:16 PM.

  5. #5
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    Well first things first. Do you know how to create a method? If so do that and label it calculatePay. Then calculate the answer using the values you were given and return it.

    Also your logic is flawed. You have over time as being paid 150% for each hour worked regardless if its overtime. It needs to be ((totalHoursWorked - 40) * 1.5) + (40*regularWages))

  6. #6
    afrttoh is offline Member
    Join Date
    Nov 2008
    Location
    London
    Posts
    39
    Rep Power
    0

    Default

    Quote Originally Posted by xcallmejudasx View Post
    Well first things first. Do you know how to create a method? If so do that and label it calculatePay. Then calculate the answer using the values you were given and return it.

    Also your logic is flawed. You have over time as being paid 150% for each hour worked regardless if its overtime. It needs to be ((totalHoursWorked - 40) * 1.5) + (40*regularWages))
    Thank you ill give it a go.

Similar Threads

  1. Replies: 2
    Last Post: 11-08-2008, 04:58 AM
  2. Replies: 2
    Last Post: 07-11-2008, 09:41 AM
  3. Replies: 3
    Last Post: 12-25-2007, 04:10 AM
  4. Seems so simple yet I can't figure it out!
    By adamhaviland in forum New To Java
    Replies: 1
    Last Post: 11-03-2007, 06:26 PM
  5. I can't figure this out
    By silvia in forum New To Java
    Replies: 3
    Last Post: 07-20-2007, 04:38 AM

Posting Permissions

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