Results 1 to 4 of 4
  1. #1
    Goswamotho is offline Member
    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Default Including overtime in payrole program

    Hello I have a problem i need to solve regarding including overtime on my program..can someone sjow me where to include overtime what methods and attributes to include within this payroll program?

    package week3payroll2;

    /**
    *
    * @author DITSEBE
    */
    import java.util.Scanner; // class Scanner
    public class Week3payroll2

    {
    //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 cleanInputBuffer; //input
    String employeeName; // input
    double hourlyRate; // input
    double hoursWorked; // input
    double sum; // weekly pay
    boolean end = false; // is the input name stop?
    while (end == false) // as long as end is false, proceed
    {
    hourlyRate = -1; // this way, both are initiated to be -1;
    hoursWorked = -1;
    System.out.print("Enter Name of Employee:");
    employeeName = input.nextLine();
    if(employeeName.toLowerCase().equals ("stop"))
    end = true; // when the stop is detected, change the boolean, which will end the while loop while(hourlyRate<0) // since this was initiated to -1, it will loop until it gets a positive value
    System.out.print("Enter a positive hourly rate:"); // prompt
    hourlyRate = input.nextDouble(); // input

    while (hoursWorked < 0) // same as hourlyRate while loop
    {
    System.out.print("Enter a positive number of hours worked:"); // prompt
    hoursWorked = input.nextDouble(); // input
    }
    sum = hourlyRate * hoursWorked; // * numbers

    System.out.printf("The employee %s was paid $ %.2f this week", employeeName, sum);
    //Clean the input buffer
    cleanInputBuffer = input.nextLine(); //Read a line of text to clean the input buffer
    } // end outer while

    } // end method main

    } // end class PayrollProgramPart

  2. #2
    Goswamotho is offline Member
    Join Date
    Apr 2013
    Posts
    2
    Rep Power
    0

    Default Re: log4j not finding log4j.xml "there-aint-no-such-file"

    package week3payroll2;

    /**
    *
    * @author DITSEBE
    */
    import java.util.Scanner; // class Scanner
    public class Week3payroll2

    {
    //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 cleanInputBuffer; //input
    String employeeName; // input
    double hourlyRate; // input
    double hoursWorked; // input
    double sum; // weekly pay
    boolean end = false; // is the input name stop?
    while (end == false) // as long as end is false, proceed
    {
    hourlyRate = -1; // this way, both are initiated to be -1;
    hoursWorked = -1;
    System.out.print("Enter Name of Employee:");
    employeeName = input.nextLine();
    if(employeeName.toLowerCase().equals ("stop"))
    end = true; // when the stop is detected, change the boolean, which will end the while loop while(hourlyRate<0) // since this was initiated to -1, it will loop until it gets a positive value
    System.out.print("Enter a positive hourly rate:"); // prompt
    hourlyRate = input.nextDouble(); // input

    while (hoursWorked < 0) // same as hourlyRate while loop
    {
    System.out.print("Enter a positive number of hours worked:"); // prompt
    hoursWorked = input.nextDouble(); // input
    }
    sum = hourlyRate * hoursWorked; // * numbers

    System.out.printf("The employee %s was paid $ %.2f this week", employeeName, sum);
    //Clean the input buffer
    cleanInputBuffer = input.nextLine(); //Read a line of text to clean the input buffer
    } // end outer while

    } // end method main

    } // end class PayrollProgramPart



    Modify the Payroll Program application so it continues to request employee information until the user enters stop as the employee name. In addition, program the application to check that the hourly rate and number of hours worked are positive numbers. If either the hourly rate or the number of hours worked is not a positive value, the application should prompt the user to enter a positive amount. Lastly, modify the program to calculate overtime pay. Regular hours are considered to be 40 hours or less. Overtime is considered to be any hours worked over 40. When someone works greater than 40 hours, they are paid 1.5 times the amount of their base pay for each of the hours worked over 40. Update your weekly pay calculations to determine the pay for an employee, accounting for any overtime worked.

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Including overtime in payrole program

    Please don't hijack someone else's post. I have moved your posts to their own thread.

  4. #4
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    393
    Rep Power
    5

    Default Re: Including overtime in payrole program

    Hello Goswamotho, welcome to the forums.

    Please enclose your code in [code] tags as it makes it much easier to read. This question also belongs in basic Java, hopefully one of the mods might oblige .

    Apart from the fact this looks like a homework dump the alterations required are simple enough. All that is required is that you will ensure the hours worked are 40 or less. If not then deduct 40 from the value and multiply this by 1.5 times the rate of pay. Add 40 times the rate of pay and this is the total pay for the week.

    Regards.

Similar Threads

  1. Overtime Pay Program
    By Kaosuvls in forum New To Java
    Replies: 1
    Last Post: 02-24-2012, 04:57 AM
  2. Including a .dll file
    By abalis3 in forum Eclipse
    Replies: 1
    Last Post: 01-16-2012, 01:40 AM
  3. Sum of all even numbers up to but not including 100
    By bigpips305 in forum New To Java
    Replies: 41
    Last Post: 02-09-2010, 03:16 PM
  4. Including JAR in applications
    By bugger in forum New To Java
    Replies: 0
    Last Post: 01-11-2008, 09:36 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
  •