SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 15 Oct 2017 My Price 10.00

how do I get started writing this code?

how do I get started writing this code?

Next, rewrite class CommissionEmployee from Section 9.4.5 as a subclass of Employee. Class CommissionEmployee should contain only the instance variables and methods that are not declared in superclass Employee. Class CommissionEmployee's constructor should invoke class Employee's constructor and CommissionEmployee's toString method should invoke Employee's toString method.

Once you've completed these modifications, run the BasePlusCommissionEmployeeTest app using these new classes to ensure that the app still displays the same results for a BasePlusCommissionEmployee object.

 

 

// Fig. 9.11: BasePlusCommissionEmployee.java
// BasePlusCommissionEmployee class inherits from CommissionEmployee 
// and accesses the superclass's private data via inherited 
// public methods.

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;
   }
   
   // 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 BasePlusCommissionEmployee
   @Override
   public String toString()
   {
      return String.format("%s %s%n%s: %.2f", "base-salaried",
         super.toString(), "base salary", getBaseSalary());   
   } 
} // end class BasePlusCommissionEmployee


/**************************************************************************
 * (C) Copyright 1992-2014 by Deitel & Associates, Inc. and               *
 * Pearson Education, Inc. All Rights Reserved.                           *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 *************************************************************************/

// BasePlusCommissionEmployeeTest.java

// Testing class BasePlusCommissionEmployee.

public class BasePlusCommissionEmployeeTest

{

  public static void main(String[] args)

  {

     // instantiate CommissionEmployee object

     CommissionEmployee employee1 = new CommissionEmployee(

        "Sue", "Jones", "222-22-2222", 10000, .06);     

     // get commission employee data

     System.out.println(

        "Employee information obtained by get methods:");

     System.out.printf("%n%s %s%n", "First name is",

        employee1.getFirstName());

     System.out.printf("%s %s%n", "Last name is",

        employee1.getLastName());

     System.out.printf("%s %s%n", "Social security number is",

        employee1.getSocialSecurityNumber());

     System.out.printf("%s %.2f%n", "Gross sales is",

        employee1.getGrossSales());

     System.out.printf("%s %.2f%n", "Commission rate is",

        employee1.getCommissionRate());

     employee1.setGrossSales(5000);

     employee1.setCommissionRate(.1);

     System.out.printf("%n%s:%n%n%s%n",                               

        "Updated employee information obtained by toString", employee1);

     // instantiate BasePlusCommissionEmployee object

     BasePlusCommissionEmployee employee2 =

        new BasePlusCommissionEmployee(

           "Bob", "Lewis", "333-33-3333", 5000, .04, 300);

     // get base-salaried commission employee data

     System.out.println(

        "Employee information obtained by get methods:");

     System.out.printf("%n%s %s%n", "First name is",

        employee2.getFirstName());

     System.out.printf("%s %s%n", "Last name is",

        employee2.getLastName());

     System.out.printf("%s %s%n", "Social security number is",

        employee2.getSocialSecurityNumber());

     System.out.printf("%s %.2f%n", "Gross sales is",

        employee2.getGrossSales());

     System.out.printf("%s %.2f%n", "Commission rate is",

        employee2.getCommissionRate());

     System.out.printf("%s %.2f%n", "Base salary is",

        employee2.getBaseSalary());

     employee2.setBaseSalary(1000);

     System.out.printf("%n%s:%n%n%s%n",

        "Updated employee information obtained by toString",

        employee2.toString());

  } // end main

} // end class BasePlusCommissionEmployeeTest

 

/**************************************************************************

 * (C) Copyright 1992-2014 by Deitel & Associates, Inc. and              *

 * Pearson Education, Inc. All Rights Reserved.                          *

 *                                                                       *

 * DISCLAIMER: The authors and publisher of this book have used their    *

 * best efforts in preparing the book. These efforts include the         *

 * development, research, and testing of the theories and programs       *

 * to determine their effectiveness. The authors and publisher make      *

 * no warranty of any kind, expressed or implied, with regard to these   *

 * programs or to the documentation contained in these books. The authors *

 * and publisher shall not be liable in any event for incidental or      *

 * consequential damages in connection with, or arising out of, the      *

 * furnishing, performance, or use of these programs.                    *

 *************************************************************************/

Answers

(5)
Status NEW Posted 15 Oct 2017 10:10 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)