I need help in getting the second output to show both the commission rate and the earnings for the String method output
package CompemsationTypes;
public class BasePlusCommissionEmployee extends CommissionEmployee
{
public void setGrossSales(double grossSales) {
super.setGrossSales(grossSales);
}
public double getGrossSales() {
return super.getGrossSales();
}
public void setCommissionRate(double commissionRate) {
super.setCommissionRate(commissionRate);
}
public double getCommissionRate() {
return super.getCommissionRate();
}
public String getFirstName() {
return super.getFirstName();
}
public String getLastName() {
return super.getLastName();
}
public String getSocialSecurityNumber() {
return super.getSocialSecurityNumber();
}
private double baseSalary;
public BasePlusCommissionEmployee(String firstName,String lastName,
String socialSecurityNumber,
double grossSales, double commissionRate,double baseSalary)
{
super(firstName, lastName, socialSecurityNumber,grossSales, commissionRate);
if (baseSalary < 0.0)
throw new IllegalArgumentException("Base salary must be >= 0.0");
this.baseSalary = baseSalary;
}
public void setBaseSalary(double baseSalary){
if (baseSalary < 0.0)
throw new IllegalArgumentException("Base salary must be >= 0.0");
this.baseSalary = baseSalary;
}
public double getBaseSalary(){
return baseSalary;
}
@Override
public double earnings(){
return getBaseSalary() + super.earnings();
}
@Override
public String toString(){
return String.format("%s %s%n%s: %.2f", "base-salaried",
super.toString(), "base salary", getBaseSalary());
}
}
package CompemsationTypes;
public class BasePlusCommissionEmployeeTest{
public static void main(String[] args){
BasePlusCommissionEmployee employee = new BasePlusCommissionEmployee("John",
"Davis","615-818-7941", 1250, .07, 410);
System.out.println("Employee information gained using get methods:");
System.out.printf("%s %s%n", "First name is",employee.getFirstName());
System.out.printf("%s %s%n", "Last name is",employee.getLastName());
System.out.printf("%s %s%n", "Social security number is",
employee.getSocialSecurityNumber());
System.out.printf("%s %.2f%n", "Gross sales is",employee.getGrossSales());
System.out.printf("%s %.2f%n", "Commission rate is",employee.getCommissionRate());
System.out.printf("%s %.2f%n", "Base salary is",employee.getBaseSalary());
System.out.printf("%s %.2f%n", "Employee Earnings are",employee.earnings());
employee.setBaseSalary(1800);
employee.setCommissionRate(.1);
employee.earnings();
System.out.printf("%n%s:%n%n%s%n","Updated employee information, Dynamicly altered using the"
+ " toString Method",employee.toString());
}
}
package CompemsationTypes;
public class CommissionEmployee extends Employee{
private double grossSales;
private double commissionRate;
public CommissionEmployee(String firstName,String lastName,
String socialSecurityNumber,double grossSales,double commissionRate){
super(firstName, lastName, socialSecurityNumber);
if (grossSales < 0.0)
throw new IllegalArgumentException("Gross sales must be >= 0.0");
if (commissionRate <= 0.0 || commissionRate >= 1.0)
throw new IllegalArgumentException("Commission rate must be > 0.0 and "
+ "< 1.0");
this.grossSales = grossSales;
this.commissionRate = commissionRate;
}
public void setGrossSales(double grossSales){
if (grossSales < 0.0)
throw new IllegalArgumentException("Gross sales must be >= 0.0");
this.grossSales = grossSales;
}
public double getGrossSales(){
return grossSales;
}
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;
}
public double getCommissionRate(){
return commissionRate;
}
public double earnings(){
return grossSales * commissionRate;
}
public String toString(){
return super.toString()+String.format("%n%s: %.2f%n%s: %.2f","gross sales",
grossSales,"commission rate", commissionRate, "earnings",grossSales * commissionRate );
}
}
package CompemsationTypes;
public class CommissionEmployeeTest{
public static void main(String[] args){
CommissionEmployee employee = new CommissionEmployee("Vincent", "Carter",
"742-27-8544", 18000, .06);
System.out.println("Employee information gained using get methods:");
System.out.printf("%s %s%n", "First name is",employee.getFirstName());
System.out.printf("%s %s%n", "Last name is",employee.getLastName());
System.out.printf("%s %s%n", "Social security number is",
employee.getSocialSecurityNumber());
System.out.printf("%s %.2f%n", "Gross sales is",employee.getGrossSales());
System.out.printf("%s %.2f%n", "Commission rate is",employee.getCommissionRate());
employee.setGrossSales(13000);
employee.setCommissionRate(.4);
System.out.printf("%n%s:%n%n%s%n","Updated employee information, Dynamicly altered using the"
+ " toString Method", employee);
}
}
package CompemsationTypes;
public class Employee{
private final String firstName;
private final String lastName;
private final String socialSecurityNumber;
public Employee(String firstName,String lastName, String socialSecurityNumber){
this.firstName = firstName;
this.lastName = lastName;
this.socialSecurityNumber = socialSecurityNumber;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public String getSocialSecurityNumber(){
return socialSecurityNumber;
}
@Override
public String toString(){
return String.format("%s: %s %s%n%s: %s","commission employee", firstName,
lastName,"social security number", socialSecurityNumber);
}
}
If you have any doubts, please give me comment...
public class CommissionEmployee extends Employee {
private double grossSales;
private double commissionRate;
public CommissionEmployee(String firstName, String lastName, String socialSecurityNumber, double grossSales,
double commissionRate) {
super(firstName, lastName, socialSecurityNumber);
if (grossSales < 0.0)
throw new IllegalArgumentException("Gross sales must be >= 0.0");
if (commissionRate <= 0.0 || commissionRate >= 1.0)
throw new IllegalArgumentException("Commission rate must be > 0.0 and " + "< 1.0");
this.grossSales = grossSales;
this.commissionRate = commissionRate;
}
public void setGrossSales(double grossSales) {
if (grossSales < 0.0)
throw new IllegalArgumentException("Gross sales must be >= 0.0");
this.grossSales = grossSales;
}
public double getGrossSales() {
return grossSales;
}
![[anunaga@anunaga 15052018]$ javac CommissionEmployeeTest.java [anunagaanunaga 15052018]$ java CommissionEmployeeTest Employee](http://img.homeworklib.com/questions/e84b6230-b813-11ea-b19a-210fa122a780.png?x-oss-process=image/resize,w_560)
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;
}
public double getCommissionRate() {
return commissionRate;
}
public double earnings() {
return grossSales * commissionRate;
}
public String toString() {
return super.toString() + String.format("\n%s: %.2f\n%s: %.2f\n%s: %.2f\n", "gross sales", grossSales, "commission rate", commissionRate, "earnings", grossSales * commissionRate);
}
}
I need help in getting the second output to show both the commission rate and the...
Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is a kind of CommissionEmployee with the following differences and specifications: HourlyPlusCommissionEmployee earns money based on 2 separate calculations: commissions are calculated by the CommissionEmployee base class hourly pay is calculated exactly the same as the HourlyEmployee class, but this is not inherited, it must be duplicated in the added class BasePlusCommissionEmployee inherits from CommissionEmployee and includes (duplicates) the details of SalariedEmployee. Use this as...
HOW TO FiX EXCEPTIONS??? In order to populate the array, you will need to split() each String on the (,) character so you can access each individual value of data. Based on the first value (e.g., #) your method will know whether to create a new Manager, HourlyWorker, or CommissionWorker object. Once created, populate the object with the remaining values then store it in the array. Finally, iterate through the array of employees using the enhanced for loop syntax, and...
What is wrong with this Code? Fix the code errors to run correctly without error. There are four parts for one code, all are small code segments for one question. public class StudentTest { public static void main(String[] args){ // Part Time Student Test Student ft1 = new PartTimeStudent("George", "Bush", "123-12-5678", 1, 2 ); System.out.println(ft1); Student ft2 = new PartTimeStudent("Abraham", "Lincoln", "001-90-5323", 6, 22 ); System.out.println(ft2); // Full Time Student Test Student pt1 = new FullTimeStudent("Nikola", "Tesla", "442-00-0998", 8, 26...
By editing the code below to include composition, enums, toString; must do the following: Prompt the user to enter their birth date and hire date (see Fig. 8.7, 8.8 and 8.9 examples) in addition to the previous user input Create a new class that validates the dates that are input (can copy date class from the book) Incorporate composition into your class with these dates Use enums to identify the employee status as fulltime (40 or more hours worked for...
NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the current displayed customer PLEASEEEEEEEEEE package bankexample; import java.util.UUID; public class Customer { private UUID id; private String email; private String password; private String firstName; private String lastName; public Customer(String firstName, String lastName, String email, String password) { this.id = UUID.randomUUID(); this.firstName = firstName; this.lastName = lastName; this.email = email; this.password = password; } public String getFirstName() { return firstName; } public void setFirstName(String...
In the processLineOfData, write the code to handle case "H" of the switch statement such that: An HourlyEmployee object is created using the firstName, lastName, rate, and hours local variables. Notice that rate and hours need to be converted from String to double. You may use parseDouble method of the Double class as follows: Double.parseDouble(rate) Call the parsePaychecks method in this class passing the HourlyEmployee object created in the previous step and the checks variable. Call the findDepartment method...
In the processLineOfData method, write the code to handle case "H" of the switch statement such that: • An HourlyEmployee object is created using the firstName, lastName, rate, and hours local variables. Notice that rate and hours need to be converted from String to double. You may use parseDouble method of the Double class as follows: Double.parseDouble(rate) Call the parsePaychecks method in this class passing the Hourly Employee object created in the previous step and the checks variable. Call the...
In Java Programming Complete the Code that remains to be implemented follow the guide lines here and finish what code remains name of program class Student.java package course; public class Student { private String firstName; private String lastName; private Address homeAddress; private Address schoolAddress; private double[] testScores; // Four parameter constructor public Student(String firstName, String lastName, Address homeAddress, Address schoolAddress) { // Call the seven parameter constructor. Pass zeros for the three grades } // Five parameter constructor public Student(String...
What is wrong with this Code? Fix the code errors to run correctly without error. There are two parts for one code (one question) the two parts branch off, one part has 2 sheets of code, the other has 3 sheets of code, all are small code segments for one question. Pt.1 - 2 sheets of code: public class Computer { private String make; private String type; private String modelNumber; private double cpuSpeed_GHz; private int ramSize_GB; private int hardDriveSize_GB; private...
I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student { private String firstName; private String lastName; private String id; private boolean tuitionPaid; public Student(String firstName, String lastName, String id, boolean tuitionPaid) { this.firstName=firstName; this.lastName=lastName; this.id=id; this.tuitionPaid=tuitionPaid; } ...