Project #45896 - Java Project(NetBeans) Program calculates the average salary between employees

Project involves writing a program that computes the average salary for a collection of employees of different types. This program consists of four classes. The first class is the Employee class, which contains the employee's name and monthly salary, which is specified in whole dollars. It should have two methods:

  1. A constructor that allows the name and monthly salary to be initialized.
  2. A method named annualSalary that returns the salary for a whole year.

The Employee class has two subclasses. The first is Salesman. It has an additional instance variable that contains the annual sales in whole dollars for that salesman. It should have the same two methods:

  1. A constructor that allows the name, monthly salary and annual sales to be initialized.
  2. An overridden method annualSalary that returns the salary for a whole year. The salary for a salesman consists of the base salary computed from the monthly salary plus a commission. The commission is computed as 2% of that salesman's annual sales. The maximum commission a salesman can earn is $20,000.

The second subclass is Executive. It has an additional instance variable that reflects the current stock price. It should have the same two methods:

  1. A constructor that allows the name, monthly salary and stock price to be initialized.
  2. An overridden method annualSalary that returns the salary for a whole year. The salary for an executive consists of the base salary computed from the monthly salary plus a bonus. The bonus is $30,000 if the current stock price is greater than $50 and nothing otherwise.

Finally there should be a fourth class than contains the main method. It should create an array of objects of type Employee and initialize them to a mixture of different kinds of employees. It should then compute and display the average salary for all employees.

Be sure to follow good programming style, which means making all instance variable private and naming all constants. Furthermore you must select enough different kinds of employees to completely test the program.

This is what I have so far (please elavorate from this):

package averagesalary;

 

public class AverageSalaryMain{

//it needs four salesman names and four executive names

    public static void main(String[] args) {

        Employee[]names = {new Salesman("Eric Smith", 0, 0),

            new Executive("Mary Brown",0,0), new Salesman("David Taylor",0,0),

            new Executive("Alexander Moore",0,0)};

    }

}

 

package averagesalary;

 

public class Employee {

   

    private final String name;

    public int monthlySalary;

   

    public Employee (String name, int monthlySalary){

        this.name = name;

        this.monthlySalary = monthlySalary;

    }

    public double annualSalary (){

        return (double) monthlySalary * 12;

    }

}

package averagesalary;

 

public class Salesman extends Employee{

    private static double annualSales = 0;

 

    public Salesman(String name, int monthlySalary,double annualSales) {

        super(name, monthlySalary);

        Salesman.annualSales = annualSales;

    }

    @Override

    public double annualSalary(){

        if(annualSales * 0.2 <= 20000){

            return (double) annualSales * 0.2 + monthlySalary;

        }

        else{

            return (double) annualSales * 0.2 - 20000;

        }

    }

}

 

package averagesalary;

 

public class Executive extends Employee{

    private static double CurrentStockPrice = 0;

 

    public Executive(String name, int monthlySalary, double stockPrice) {

        super(name, monthlySalary);

        Executive.CurrentStockPrice = stockPrice;

    }

    @Override

    public double annualSalary(){

       if (CurrentStockPrice > 50){

           return(double)monthlySalary + 30000;

       }

       else{

           return 0;

       }

    }

}

 

Subject Computer
Due By (Pacific Time) 11/02/2014 12:00 am
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy