Question
help please
Perform the following steps: a) Using NetBeans, Create a New Java Application Project with Project Name BasePlusCommission Em


This assignment is to write a program with three classes: 1) a super class CommissionEmployee, 2) a subclass BasePlusCommissi
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

CommissionEmployee class

public class CommissionEmployee {
  
private final String firstName;
private final String lastName;
private final String socialSecurityNumber;
private double grossSales;//gross weekly sales
private double commissionRate;//commission percentage
  
//five-argument constructor
public CommissionEmployee(String firstName, String lastName,
String socialSecurityNumber, double grossSales,
double commissionRate)
{
//implicit call to Object's default constructor occurs here
  
//if grossSale is invalid throw exception
if (grossSales < 0.0)
throw new IllegalArgumentException(
"Gross sales must be >= 0.0");
  
//if commissionRate is invalid throw exception
if (commissionRate <= 0.0 || commissionRate >= 1.0)
throw new IllegalArgumentException(
"Commission rate must be > 0.0 and < 1.0");
  
this.firstName = firstName;
this.lastName = lastName;
this.socialSecurityNumber = socialSecurityNumber;
this.grossSales = grossSales;
this.commissionRate = commissionRate;
}//end constructor
  
//return first name
public String getFirstName()
{
return firstName;
}
  
//return last name
public String getLastName()
{
return lastName;
}
  
//return social security number
public String getSocialSecurityNumber()
{
return socialSecurityNumber;
}
  
//set gross sales amount
public void setGrossSales(double grossSales)
{
if (grossSales < 0.0)
throw new IllegalArgumentException(
"Gross sales must be >= 0.0");
this.grossSales = grossSales;
}
  
//return gross sales amount
  
public double getGrossSales()
{
return grossSales;
}
  
//set commission rate
public void setCommissionRate(double commissionRate)
{
if (commissionRate <= 0.0 || commissionRate >= 1.0)
throw new IllegalArgumentException(
"Commission rate must be > 0.0 and < 1.0");
this.commissionRate = commissionRate;
}
  
//return gross sales amount
  
public double getCommissionRate()
{
return commissionRate;
}
  
//calculate earnings
public double earnings()
{
return commissionRate * grossSales;
}
//return string representation of commissionEmploee object
@Override//indicates that this method overrides a superclass method
public String toString()
{
return String.format("%s: %s %s%n%s: %s%n%s: %.2f%n%s: %.2f",
"commission employee", firstName, lastName,
"social security number", socialSecurityNumber,
"gross sales", grossSales,
"commission rate", commissionRate);
}
}

BasePlusCommissionEmployee class

public class BasePlusCommissionEmployee extends CommissionEmployee{
private double baseSalary;//base salary per week
  
//six-argument constructor
public BasePlusCommissionEmployee(String firstName, String lastName,
String socialSecurityNumber, double grossSales,
double commissionRate, double baseSalary)
{
super(firstName, lastName, socialSecurityNumber,
grossSales, commissionRate);
  
//if baseSalary is invalid throw exception
if (baseSalary < 0.0)
throw new IllegalArgumentException(
"Base salary must be >= 0.0");
  
this.baseSalary = baseSalary;
}//end constructor
  
  
//set base salary
public void setBaseSalary(double baseSalary)
{
if (baseSalary < 0.0)
throw new IllegalArgumentException(
"Base salary must be >= 0.0");
this.baseSalary = baseSalary;
}
  
//return base salary
public double getBaseSalary()
{
return baseSalary;
}
  
//calculate earnings
@Override
public double earnings()
{
return getBaseSalary() + super.earnings();
}
//return string representation of commissionEmploee object
@Override//indicates that this method overrides a superclass method
public String toString()
{
return String.format("%s %s%n%s: %.2f", "base-salaried",
super.toString(), "base salary", getBaseSalary());
}
}

BasePlusCommissionEmployeeTest class

/*
* Course Name:
* Your Name:
* Title:
*/


public class BasePlusCommissionEmployeeTest {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
BasePlusCommissionEmployee BPemp1=new BasePlusCommissionEmployee("Bob", "Lewis", "333-33-3333", 5000, 0.04, 300);
BasePlusCommissionEmployee BPemp2=new BasePlusCommissionEmployee( "Mary","Sanchez", "123-45-6789", 6500, 0.05, 250);
System.out.println(BPemp1);
System.out.println("Total Earnings: "+BPemp1.earnings()+"\n");
System.out.println(BPemp2);
System.out.println("Total Earnings: "+BPemp2.earnings()+"\n");
  
  
}
  
}
output

Output Debugger Console x BasePlusCommissionEmployeeTest (run) x run: base-salaried commission employee: Bob Lewis social sec

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
help please Perform the following steps: a) Using NetBeans, Create a New Java Application Project with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • signature 1. Create a new NetBeans Java project. The name of the project has to be...

    signature 1. Create a new NetBeans Java project. The name of the project has to be the first part of the name you write on the test sheet. The name of the package has to be testo You can chose a name for the Main class. (2p) 2. Create a new class named Address in the test Two package. This class has the following attributes: city: String-the name of the city zip: int - the ZIP code of the city...

  • In this assignment, you will implement Address and Residence classes. Create a new java project. Part...

    In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...

  • MasterMind in Java Activity MasterMind project Create a new Java Application project named MasterMind allowing Netbeans...

    MasterMind in Java Activity MasterMind project Create a new Java Application project named MasterMind allowing Netbeans IDE to create the main class called MasterMind.java MasterMind class Method main() should: Call static method System.out.println() and result in displaying “Welcome to MasterMind!” Call static method JOptionPane.showMessageDialog(arg1, arg2) and result in displaying a message dialog displaying “Let’s Play MasterMind!” Instantiate an instance of class Game() constants Create package Constants class Create class Constants Create constants by declaring them as “public static final”: public...

  • Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEm...

    Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...

  • Create a New Java Project called YourLastNameUpperCase. Write a program that asks the user for the...

    Create a New Java Project called YourLastNameUpperCase. Write a program that asks the user for the names of two files. The first file should be opened for reading and the second file should be opened for writing. The program should read the contents of the first file, change all characters to uppercase, and store the results in the second file. The second file will be a copy of the first file, except that all the characters will be uppercase. Use...

  • in java : Create Java Application you are to create a project using our designated IDE...

    in java : Create Java Application you are to create a project using our designated IDE (which you must download to your laptop). Create the code to fulfill the requirements below. Demonstrate as stipulated below. Create a Main Application Class called AddressBookApplication (a counsole application / command line application). It should Contain a Class called Menu that contains the following methods which print out to standard output a corresponding prompt asking for related information which will be used to update...

  • I need help for part B and C 1) Create a new project in NetBeans called...

    I need help for part B and C 1) Create a new project in NetBeans called Lab6Inheritance. Add a new Java class to the project called Person. 2) The UML class diagram for Person is as follows: Person - name: String - id: int + Person( String name, int id) + getName(): String + getido: int + display(): void 3) Add fields to Person class. 4) Add the constructor and the getters to person class. 5) Add the display() method,...

  • Java Project Create a NetBeans project for this activity. Test Stem / Question Choices 1: Create...

    Java Project Create a NetBeans project for this activity. Test Stem / Question Choices 1: Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes. Now override the toString() method. Is this possible? A: Yes. B: No. C: In some cases where the attributes are only strings. D: Yes, as long as you explicitly extends Object class. 2: Create a class with the main method...

  • create java application with the following specifications: -create an employee class with the following attibutes: name...

    create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...

  • Create a java project. Create a class called cls2DarrayProcessor.java. with the following: Reads numbers from a...

    Create a java project. Create a class called cls2DarrayProcessor.java. with the following: Reads numbers from a pre-defined text file. A: Text file name should be data.txt B: Text file should be in the same workspace directory of your project's folder C: Text file name should be STORED in a String and called: String strFile ='./data.txt' Defines a 2-D array of integers with dimensions of 5 rows by 5 columns. Inserts the data from the text file to the 2-D array...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT