Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program: Factory Item Inventory Extract the folder FactoryItems to the Desktop. The folder contains the file factory_item_descriptions.txt. Create an interface called ComputeDeductions with the following

Program: Factory Item Inventory

Extract the folder FactoryItems to the Desktop. The folder contains the file factory_item_descriptions.txt.

Create an interface called ComputeDeductions with the following specifications:

It should have an abstract method getSalesTax that has no parameters and returns a double

It should have an abstract method getDiscount that has no parameters and returns a double

Create a class called HardDisk that extends FactoryItem and implements ComputeDeductions. It has the following specifications:

It should have the following instance variables:

hardDiskType:String

-hardDiskSize:int

It should have the following constructors:

A constructor that creates a HardDisk with the specified itemCode, itemDescription, itemCost, itemManufacturer, itemSalesTaxRate, itemDiscountRate, itemProfitMarginRate, hardDiskType and hardDiskSize. It calls the superclass constructor to assign the itemCode, itemDescription, itemCost, itemManufacturer, itemSalesTaxRate, itemDiscountRate and itemProfitMarginRate. It assigns the hardDiskType and hardDiskSize

It should have the accessor (getters) and mutator (setters) methods for its two instance variables, and a toString() method that overrides toString() in the super class to return the instance variables as a String and calls toString() in the superclass

It should have the following public methods:

A method that overrides the abstract method in the interface to compute the discount. The discount rate is applied to the cost with the following formula

Discount = cost * discount rate * 0.01

A method that overrides the abstract method in the interface to compute the sales tax. The sales tax rate is applied to the cost with the following formula

Sales tax = cost * sales tax rate * 0.01

A method that overrides the abstract method in the abstract class to compute the selling price from the cost, sales tax, discount and profit margin.

Selling price = (cost + sales tax discount) * (1.0 + profit margin rate * 0.01)

Create a class called FactoryItemInventory. The class has the following specifications:

It has two instance variables: list:ArrayList and file:File.

It has a constructor that takes a list:ArrayList and file:File and assigns it to the instance variables.

It should have the accessor (getters) and mutator (setters) methods for its instance variables and a toString() method that returns the instance variables as a String

It has a method maximumSellingPrice that has arguments array:double[], arrayLength:int and max:double. The method recursively finds the maximum double value in array and returns it. Do not use loops to implement this method, only use recursion.

It has a method maximumSellingPriceHelper that has no parameters and returns a double. The method creates an array of double. The length of the array is equal to the number of objects in list. The method enters the selling price of the objects in the list into the array. It calls method maximumSellingPrice and passes array, its length and 0. It returns the value returned by the maximumSellingPrice method.

It has a method readFactoryItemDescriptionsFromFile that has no arguments and has return type void. The method uses the instance variable file with Scanner to read the item descriptions from the text file factory_item_descriptions.txt and set them to the objects in list. The first description in the text file should be set to the first object in list. The second description in the text file should be set to the second object in list, and so on. Handle any Exceptions by printing the stack trace.

Create a class called TestFactoryItemInventory with the following specifications:

It has a main method which:Creates 3 HardDisk instances with the following itemCode, itemDescription, itemCost, itemManufacturer, itemSalesTaxRate, itemDiscountRate, itemProfitMarginRate, hardDiskType and hardDiskSize. The descriptions are empty Strings and will be read later from the text file.

"A1101", "" , 60.50, "Seagate", 8.5, 5.0, 10.0, "SATA", 2

"A1102", "" , 65.50, "Seagate", 8.5, 5.0, 10.0, "SATA II", 4

"A1103", "" , 73.50, "Seagate", 8.5, 5.0, 10.0, "SATA III", 8

Prints on screen the itemCode, itemDescription, itemCost, itemManufacturer, itemSalesTaxRate, itemDiscountRate, itemProfitMarginRate, hardDiskType, hardDiskSize, sales tax, discount and selling price of the HardDisk instances. The sales tax, discount and selling price must be formatted to two decimal places

Adds the 3 HardDisk instances to a list:ArrayList. Creates a file:File and assigns it a File object containing the file path to the FactoryItems folder and the file name factory_item_descriptions.txt. Creates an object inventory: FactoryItemInventory and passes list and file to it. Calls the method maximumSellingPriceHelper. Displays the maximum selling price returned by the method. The maximum selling price must be formatted to two decimal places. Calls the readFactoryItemDescriptionsFromFile method. Display the Factory item inventory by getting the list from the object inventory and printing it.

The console output of the program should be readable and similar to the screenshots below. You are allowed to rewrite the toString() methods in all classes including the FactoryItem class. Also, you are allowed to use print statements and newline characters as you require.

package testsample2;

public abstract class FactoryItem {

private String itemCode;

private String itemDescription;

private double itemCost;

private String itemManufacturer;

private double itemSalesTaxRate;

private double itemDiscountRate;

private double itemProfitMarginRate;

/**

* @param itemCode

* @param itemDescription

* @param itemCost

* @param itemManufacturer

* @param itemSalesTaxRate

* @param itemDiscountRate

* @param itemProfitMarginRate

*/

public FactoryItem(String itemCode, String itemDescription, double itemCost,

String itemManufacturer, double itemSalesTaxRate,

double itemDiscountRate, double itemProfitMarginRate) {

this.itemCode = itemCode;

this.itemDescription = itemDescription;

this.itemCost = itemCost;

this.itemManufacturer = itemManufacturer;

this.itemSalesTaxRate = itemSalesTaxRate;

this.itemDiscountRate = itemDiscountRate;

this.itemProfitMarginRate = itemProfitMarginRate;

}

/**

* @return the itemCode

*/

public String getItemCode() {

return itemCode;

}

/**

* @param itemCode the itemCode to set

*/

public void setItemCode(String itemCode) {

this.itemCode = itemCode;

}

/**

* @return the itemDescription

*/

public String getItemDescription() {

return itemDescription;

}

/**

* @param itemDescription the itemDescription to set

*/

public void setItemDescription(String itemDescription) {

this.itemDescription = itemDescription;

}

/**

* @return the itemCost

*/

public double getItemCost() {

return itemCost;

}

/**

* @param itemCost the itemCost to set

*/

public void setItemCost(double itemCost) {

this.itemCost = itemCost;

}

/**

* @return the itemManufacturer

*/

public String getItemManufacturer() {

return itemManufacturer;

}

/**

* @param itemManufacturer the itemManufacturer to set

*/

public void setItemManufacturer(String itemManufacturer) {

this.itemManufacturer = itemManufacturer;

}

/**

* @return the itemSalesTaxRate

*/

public double getItemSalesTaxRate() {

return itemSalesTaxRate;

}

/**

* @param itemSalesTaxRate the itemSalesTaxRate to set

*/

public void setItemSalesTaxRate(double itemSalesTaxRate) {

this.itemSalesTaxRate = itemSalesTaxRate;

}

/**

* @return the itemDiscountRate

*/

public double getItemDiscountRate() {

return itemDiscountRate;

}

/**

* @param itemDiscountRate the itemDiscountRate to set

*/

public void setItemDiscountRate(double itemDiscountRate) {

this.itemDiscountRate = itemDiscountRate;

}

/**

* @return the itemProfitMarginRate

*/

public double getItemProfitMarginRate() {

return itemProfitMarginRate;

}

/**

* @param itemProfitMarginRate the itemProfitMarginRate to set

*/

public void setItemProfitMarginRate(double itemProfitMarginRate) {

this.itemProfitMarginRate = itemProfitMarginRate;

}

/* (non-Javadoc)

* @see java.lang.Object#toString()

*/

@Override

public String toString() {

return "FactoryItem [itemCode=" + itemCode

+ ", itemDescription=" + itemDescription

+ ", itemCost=" + itemCost

+ ", itemManufacturer=" + itemManufacturer

+ ", itemSalesTaxRate=" + itemSalesTaxRate

+ ", itemDiscountRate=" + itemDiscountRate

+ ", itemProfitMarginRate=" + itemProfitMarginRate + "]";

}

/**

* @return the selling price

*/

public abstract double getSellingPrice();

}

factory item discription

2 TB 2.5" SATA 6Gb/s 5400RPM

4 TB 2.5" SATA 6Gb/s 7200RPM

8 TB 3.5" SATA 6Gb/s 7200RPM

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_2

Step: 3

blur-text-image_3

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago