Results 1 to 2 of 2
  1. #1
    gusten is offline Member
    Join Date
    Jul 2013
    Posts
    19
    Rep Power
    0

    Default Employee Program

    Hi everyone I have a very basic understanding of Java, and find it very difficult to learn, so I hope I am in the right place. I am currently working on this project and here are the instructions:

    Write a program that makes use of a class called Employee that will calculate an employee's weekly paycheque. Design your class based on the UML diagram to the right as well as the following notes:

    A static field, empCount, keeps track of the number of instantiated employees and can be retrieved using the static method getCount( )
    The constructor initializes the employee's name and employee number (a random number in the range of 1000 - 9999)
    The method setEmployeePay( ) is overloaded to accomodate different payment methods based on empType:

    Type 1 - Salaried employees have a yearly salary, payed on a weekly basis
    Type 2 - Hourly employees are paid an hourly rate for the number of hours worked (overtime is time and a half for hours over 40)
    Type 3 - Piece employees are paid a base amount plus $24.00 for every piece completed

    The method calculatePay( ) will determine what the employee's weekly pay is, based on their payment type
    The methods getName( ) and getNumber( ) return the employee's name and employee number respectively
    All input & output should be displayed in the main class only

    The main program should test your class by instantiating four different employees:

    Test a salaried employee
    Test two hourly employees, one who has worked overtime and one who hasn't
    Test a piecework employee
    The following data can be hard-coded into your program (no prompts to enter data other than the names):

    Employee 1: (22.50, 35.0)
    Employee 2: (45350.00)
    Employee 3: (500.00, 25)
    Employee 4: (14.75, 48.0)

    And the output...

    Enter a name: Bob
    Employee count is 1
    Enter a name: Ted
    Employee count is 2
    Enter a name: Carol
    Employee count is 3
    Enter a name: Alice
    Employee count is 4

    Employee 1583 Bob earned: $787.50
    Employee 4891 Ted earned: $872.12
    Employee 7954 Carol earned: $1,100.00
    Employee 5497 Alice earned: $767.00

    UML Diagram

    Now I'm not gonna lie, I have no idea where to start. I will post my code but I am nowhere near done.


    Java Code:
    public class Lab01 {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
            // Declare variables
            int empCount;   //number of objects in memory
            String empName; //employee name
            int empNumber;  //employee number
            double empSalary;   //employee salary
            double empRate; //employee pay rate
            double empHours;    //employee hours worked
            double empBase; //employee base pay rate
            int empPieces;  //extra pieces made by employee
            int empType;    //employee type
            
            public double calculatePay()
    {
     if(empType == 1)
     { 
     setEmployeePay(45350.00);
     empSalary = empSalary / 52;
     return empSalary;
     }else
     if (empType == 2 && empCount == 1)
     {
     setEmployeePay(22.50  35.0);
     return empRate * empHours;
     }else 
     if (empType == 2 && empCount == 4)
     {
     setEmployeePay(14.75  48.0);
     return empRate * empHours;
     }else
     if(empType == 3)
     {
     setEmployeePay(500.00  25);
     return empBase + (empPieces * 24);
     }
    I tried doing the calculatePay step but I just get a bunch of errors. Like I said any help would be greatly appreciated.
    Last edited by JosAH; 07-03-2013 at 07:12 AM. Reason: removed the boldface tags

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,501
    Rep Power
    5

    Default Re: Employee Program

    The structure of your program is off. Since this is an assignment I assume your instructor went over this for you. Do you have a textbook to reference?

    The basic structure of an executable java program is:


    Java Code:
    package pkg_name;
    
    // imports here, if any
    
    public Class ClassName{
          // instance variables here
          ClassName() {} // constructor - not required
          
          public static void main(String [] args) {
               // entry point 
          }
         
          public <return type> method1(){
          }
          public <return type> method2() {
          }
    
    }
    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Need Help in determining the income of an employee
    By Java13anZ in forum New To Java
    Replies: 2
    Last Post: 03-07-2013, 02:05 PM
  2. Calculating employee salary
    By subiedude101 in forum New To Java
    Replies: 1
    Last Post: 02-07-2011, 02:35 AM
  3. employee availability
    By mikerada6 in forum JDBC
    Replies: 3
    Last Post: 12-20-2010, 11:18 AM
  4. employee
    By srish in forum Suggestions & Feedback
    Replies: 7
    Last Post: 07-21-2010, 04:52 AM
  5. search employee id
    By raman_v in forum Java Servlet
    Replies: 2
    Last Post: 12-24-2009, 08:44 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
  •