Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify your Account superclass so that it is abstract and contains the abstract method, computeSales(). If you added default behavior in the earlier task for

Modify your Account superclass so that it is abstract and contains the abstract method, computeSales(). If you added default behavior in the earlier task for computeSales(), remove this default behavior.

Leave your implementation of computeSales() in the subclasses as:

Supplies = office supplies sold dollar amount + books sold dollar amount + apparel sold dollar amount

Services = number of hours * rate per hour.

Paper = number of pounds * price per pound

Update your design document so that the UML class diagrams reflect the abstract class and abstract method.

Modify your application so that it polymorphically processes any account objects created. Store each account object created into an array of type Account. For each element in this array, call the computeSales() method and display the results. Use the example of polymorphically processing employee objects in Chapter 10 as inspiration.

Test your application and verify your results. Take screenshots to demonstrate that your application works.

Intermediate-level Java programming should be demonstrated in your application:

There should be implemented constructors for each class.

The toString() method should be overridden to provide readable string representation of each object.

Getters and setters need to be implemented to enforce data hiding.

Code should be fully commented.

Program flow should be logical.

Behavior should be encapsulated into methods avoiding all encompassing large main() methods.

Projects should be developed in NetBeans and zipped prior to submission.

Code should compile and run free of exceptions, indicating that debugging tools were used to eliminate any run time errors.

Here is my code so far, I need it to be modified to the above standards. Thanks.

import java.util.Scanner; // java utility package is imported public class Main // main class for defineing main method {

public static void main(String []args)// Main method { ServiceAccount ser = new ServiceAccount(); // object created for class ServiceAccount System.out.println(ser.Calculate()); // Calculate method is called for ser object SuppliesAccount sup = new SuppliesAccount(); // object created for class ServiceAccount System.out.println(sup.Calculate()); //Calculate method is called for sup object Paper par = new Paper(); //object for paper class is created System.out.println(par.Calculate()); // Calculate method is called for par object } } class Accounts // clas account is defined { // variables are declared int AccountID; // accund id variable float Calculate() // calculate method is defined {return 0.0f;} //to return the values public String toString() // toString method is defined { return "x";} // return the values }

class ServiceAccount extends Accounts// class ServiceAccount inherits the Account class { public float Calculate() // Calculate method from the parent class is defined { Scanner sc = new Scanner(System.in); // Scanner class object is created System.out.print(" Enter number of hours : "); // print statement for printing the no. of //hours float var1 = sc.nextFloat();//for user input for no. of hours System.out.print(" Enter rate per hour : "); // print statement to enter the rate of hours float var2 = sc.nextFloat();// user input for no. of hours

return (var1*var2); // return the value }

}

class SuppliesAccount extends Accounts // again class Accounts is inherited by class //SuppliesAccount { public float Calculate()// method from the parent class is defined { Scanner sc = new Scanner(System.in);// Scanner class object is created // print statement for entering the sold dollar amount System.out.print(" Enter the Office SuppliesAccount sold dollar amount : "); float var1 = sc.nextFloat();// defined for user input System.out.print(" Enter the book sold dollar amount : "); // print statement to enter the //amount for the book sold float var2 = sc.nextFloat();// defined for user input System.out.print(" Enter the apparel sold dollar amount : ");// print statement to print the //sold dollar amount float var3 = sc.nextFloat(); // for user input return (var1+var2+var3); // return the result as the product of all the three variable }

}

class Paper extends Accounts// Class Account is again inherited by class paper { public float Calculate() // { Scanner sc = new Scanner(System.in); // Scanner class object System.out.print(" Enter number of pounds : "); // print statement for printing the no. of //pounds float var1 = sc.nextFloat(); System.out.print(" Enter price per pound : ");// Print satement to print the price per pound. float var2 = sc.nextFloat();

return (var1*var2); // return the vaule as the product of both } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago