Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Array Payroll System

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Array Payroll System

    This is the question , i will upload my code later , pls help me check what are the mistake that i done ... thx ^^


    Write a Java class named Employee. This class should have the following private instance variables:
    • an ID value
    • the name of a person associated with the Employee
    • a field to store a value for the annual salary
    • a field to store a reference to another Employee object (for the Employee’s boss, eventually)

    Write methods with the following signatures:
    • a public constructor for the class that will insure that Employee objects always have a ID and name fields with the signature:
    public Employee(int id, String name)
    • a method to calculate an Employee object’s salary field with the signature:
    public double calAnnualSalary(double monthlySal, double allowances, double tax
    )
    Annual salary calculation:
    Gross salary = 12 x monthlysal
    Annual salary = [Gross salary + allowances]-[gross salary x tax]
    Note* - tax in percentage
    • a method to get an Employee object’s current salary field value with the signature:
    public double getSalary( )
    • a method to set an Employee object’s field referencing another Employee object with the signature:
    public void setBoss ( Employee boss )
    • a method to return a String identifying the field contents of an Employee with the signature
    public String toString()

    You also need to write a Java class named Boss. This class will make use of the Employee class created above. Your Boss class should have the following private instance variables:
    • a bossName
    • an array named employees in which to store Employee objects
    • an int field named count to store the number of Employees who the Boss has.

    Write methods with the following signatures:
    • a public constructor for the class that will insure that Boss objects always have a name field with the signature.
    public Boss( String name )
    This constructor should also instantiate an array to store Employee objects (at least 60) and initialize the count of employee’s to 0. It should not initialize the array contents; just create the array.
    • An appropriate accessor method (for example: getBossName())
    • a method to add an Employee object to the array of Employees with the signature
    public void hire( Employee emp )
    This method should increase the count of Employees associated with the Boss as each Employee is added.
    • a method that will cause the Boss to hire a group of people. This method should have the signature
    public void staffUp()
    This method should create a number of Employee objects (at least 5) and then use the hire method to add them to the boss. You may use any names and id values you choose. One way to initialize a group of names to use would be to get them from an array that is initialized like:

    String [] names = {"John", "Paul", "George", "Ringo", "Fred" };
    You may use these names or any of your choosing and any technigue of your choosing to give each Employee a different name as an input parameter for your Employee constructor. Use any id values you choose.
    • a method to print out the Boss name followed by the names of the Employees who are managed by a Boss in an order different than they were added. This method should have the signature:
    public void list()

    You also need to write a BossEmployeeDemo class that contains a main() method. The main method for this class should:
    1. create a single instance of the Boss class,
    2. call the staffUp method on the Boss object
    - ask user to input Employee name and ID
    3. call the list method on the Boss object
    4. Be sure that you also invoke appropriate methods in Employee class when you need to hire a staff.[COLOR="Silver"]


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Array Payroll System

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    There's nothing we can do for you in this post. There's no code, no way to determine that you've made any mistakes let alone determine why you've made them or how to fix them. Please open a new thread when you're ready to show your code and describe what help you need. Ask specific questions, show actual and desired sample runs, post error messages, etc.

    Thread closed.

Similar Threads

  1. [SOLVED] Payroll assignment
    By ggx7 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 27th, 2014, 02:49 AM
  2. NEED HELP.. PAYROLL SYSTEM CONNECT TO MS ACESS
    By nyrodeguzman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 16th, 2013, 11:09 AM
  3. [SOLVED] Please help me with this payroll program
    By Leprechaun_hunter in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 14th, 2011, 06:47 PM
  4. heeeeeyyyy .. HELP ! :) -- PAYROLL SYSTEM --
    By princess in forum Java Theory & Questions
    Replies: 5
    Last Post: February 27th, 2011, 03:11 PM
  5. Payroll
    By Kesh486 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 6th, 2010, 06:48 PM