Results 1 to 4 of 4
  1. #1
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default IT 215 Java Programming

    import java.util.Scanner; // program uses class Scanner

    public class Payrollrx
    {
    // main method begins execution of Java application
    public static void main( String args[] )
    {

    // create Scanner to obtain input from command window

    Scanner input = new Scanner( System.in );

    String name; // employee's name
    int wage; // hourly rate
    int hours; // number of hours worked
    int total; // product of wage and hours

    System.out.print( "Enter employee's name: " ); // prompt user to input name
    name = input.nextLine(); //read employee's name from user's input

    System.out.print( "Enter hourly wage: " ); // prompt user for employee's hourly wage
    hours = input.nextInt(); // read hourly rate from user's input

    System.out.print( "Enter hours worked: " ); // prompt user to enter number of hours worked for the week
    wage = input.nextInt(); // read number of weeks from user's input

    total = wage * hours; // multiply numbers

    System.out.println( "The Employee " + name ); // displays employee's name
    System.out.printf( "weekly pay is $%d\n" , total ); // displays weekly pay

    } // end method main
    }

    This is a copy of my original program. Now we are being asked to make sure the request for employee information stays constant until user enter stop as the employee name. In addition, program the application to check that the hourly rate and number of hours worked is not a postive value, the application should prompt the user to enter a positive amount.

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

    Default

    we are being asked to make sure the request for employee information stays constant until user enter stop as the employee name.
    Please explain what "stays constant" means here.

    Also, why not take a shot at solving this first and showing us what you've done. Doing this will help you more, and will also help us as we'll know what you already know, and where you need help.

    Finally, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:

    Java Code:
    [code]
      // your code goes here
      // notice how the top and bottom tags are different
    [/code]
    Best of luck

  3. #3
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default

    [code]
    // Payroll.java
    // Payroll program that displays the weekly pay of the employee.
    import java.util.Scanner; // program uses class Scanner

    public class Payroll
    {
    // main method begins execution of Java application
    public static void main( String args[] )
    {
    // create Scanner to obtain input from command window
    Scanner input = new Scanner( System.in );

    int number1; // hours worked
    int number2; // hourly pay rate
    int sum; // total of hours worked multiplied by hourly pay rate

    System.out.print ( "Enter employee name: " ); // prompt
    String theName = input.nextLine(); // read a line of text
    Payroll.setEmployeeName( theName ); // set the employee name

    System.out.print( "Enter hours worked: " ); // prompt
    number1 = input.nextInt(); // read first number from user

    System.out.print( "Enter hourly pay rate: " ); // prompt
    number2 = input.nextInt(); // read second number from user

    sum = number1 * number2; // multiply hours worked * hourly pay rate
    System.out.printf( "Employee Name:,Weekly pay is $ %d\n", sum );

    // display employee name and weekly pay total

    } // end method main

    } // end class Payroll
    [code]

    C:\Documents and Settings\Tiffany Ramirez\My Documents\Payrol.java:19:
    Not a statement Payroll.setEmployeeName; (theName); set the employee name
    I haven't added a stop yet because I keep getting this error and can not figure out why I am getting it.

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default Where's Wally?

    Java Code:
    Payroll.setEmployeeName( theName );
    The above means that you're calling the setEmployeeName() method in the Payroll class... uh... where is the setEmployeeName() method ?

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. Java programming help
    By mukul9999 in forum New To Java
    Replies: 2
    Last Post: 04-30-2009, 01:36 AM
  2. Java networking programming (II)
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 12-27-2007, 06:19 PM
  3. java game programming
    By gammaman in forum New To Java
    Replies: 1
    Last Post: 12-25-2007, 01:01 AM
  4. Java Applet 3D programming
    By ramk in forum Java Applets
    Replies: 0
    Last Post: 11-28-2007, 10:36 PM
  5. Java Programming
    By JavaForums in forum Java Tutorial
    Replies: 0
    Last Post: 07-28-2007, 11:10 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
  •