Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The purpose of this project is to give students exposure to object oriented desi

ID: 3709810 • Letter: T

Question

The purpose of this project is to give students exposure to object oriented design and programming using classes and polymorphism in an application that involves arrays of objects and sorting arrays containing objects. You will write several classes for Program 8.

Please submit all classes in one file. The name of the physical program file submitted program8

Assignment: Best Office Supplies Inc, an office supply store, services many customers. As customers’ orders for office supplies are shipped, information is entered into a file. Best Office Supplies bills their customers once each month. At the end of each month, the Chief Executive Officer requests a report of all customers sorted by their customer id (from lowest to highest). The report includes their bill balance and tax liability. Write a program to produce the outstanding balance report sorted by customer ID number from the data in the text file. Below is a description of the information on the text file:

* The first line on the file contains the number of customers on the file (numeric)

* The fields below repeat for each customer:

o Customer name (String)

o Customer ID (numeric integer)

o Bill balance (numeric)

o EmailAddress (String)

o Tax liability (numeric or String)

The customers served by the office supply store are of two types: tax-exempt or non-taxexempt. For a tax-exempt customer, the tax liability field on the file is the reason for the tax exemptions: education, non-profit, government, other (String). For a non-tax exempt customer, the tax liability field is the percent of tax that the customer will pay (numeric) based on the state where the customer’s business resides.

Program requirements: From the information provided, write a solution that includes the following:

* A suitable inheritance hierarchy which represents the customers serviced by the office supply company. It is up to you how to design the inheritance hierarchy. I suggest a Customer class and appropriate subclasses.

* For all classes include the following:

o Instance variables

o Constructors

o Accessor and mutator methods

o Suitable toString() methods

o Any other appropriate methods

* Write a class program8 which utilizes the following:

o An Array of Customer objects

o A method which reads the input file provided and stores the objects in the array of Customers.

o A method which sorts the array of Customers in ascending order by the customer ID.

o A method that formats and prints the output report. The report should include the following requirements:

- Report header at the start of each page showing the name of the company, report and page number.

- Report headers for each column of information.

- One Customer per line.

- At most 45 Customers per page.

- All money amounts and percentages should be displayed with 2 decimal places and commas after each thousand.

o A sample report is shown at the end of the assignment. The report produced does not have to exactly match the sample output provided but must contain all required components listed above.

o Any other helper methods used to meet the requirements of the assignment.

o The main method will call all the other methods which will:

- Read the text file and store the objects in the array

- Sort the objects

- Format and print the report

* Test the program so that there are no errors using the input file provided, program8.txt. Note that the program will only be tested using the file posted on Blackboard. You should not submit another file.

* Record your planning time, coding time, testing time and bug fixing time. Include a comment with your name and this information at the top of the program.

Also I need to use printf for the method rather than for loop to print a list.

Sample Report Output: Note that lines have been omitted to show page headers. Your output does not have to match exactly but all information should be properly labeled, report headers and column headers displayed.

Office Supplies Inc. Customer Report Page 1

=======================

Customer ID Email Address Balance Tax Type Tax Amount

======== == ============= ====== ====== ==========

Threads2 001 purchasing@threads2.com 29,000.00 tax liable 1,450.00

DAV2 002 purchasing@dav2.org 4,860.20 non-profit

DAV3 003 purchasing@dav3.org 4,860.20 non-profit

StopandShop3 004 purchasing@stopandshop2.com 8,100.00 tax liable 486.00

  Office Supplies Inc. Customer Report   Page 2

=======================

Customer ID Email Address Balance Tax Type Tax Amount

======== == ============= ====== ====== ==========

Threads 349 purchasing@threads.com 29,000.00 tax liable 1,450.00

DAV 358 purchasing@dav.org 4,860.20 non-profit

DAV2 359 purchasing@dav2.org 4,860.20 non-profit

StopandShop 377 purchasing@stopandshop.com 8,100.00 tax liable 486.00

program8.txt

Explanation / Answer

Driver.java

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

import java.io.Reader;

import java.util.ArrayList;

import java.util.List;

public class Driver {

public static void main(String[] args) throws IOException {

List<Customer> customers = new ArrayList<Customer>();

BufferedReader reader = new BufferedReader(new FileReader(

"D:\program8.txt"));

// One way of reading the file

System.out.println("Reading the file using readLine() method:");

String contentLine = null;

while ((contentLine = reader.readLine()) != null) {

contentLine = reader.readLine();

String[] words = contentLine.split(" ");

String CustomerName = null;

int CustomerID = 0;

double billBalance = 0;

String EmailAddress = null;

String taxliability = null;

for (int i = 0; i < words.length; i++) {

CustomerName = words[0];

CustomerID = Integer.parseInt(words[1]);

billBalance = Double.parseDouble(words[2]);

EmailAddress = words[3];

taxliability = words[4];

}

Customer customer = new Customer(CustomerName, CustomerID,

billBalance, EmailAddress, taxliability);

customers.add(customer);

}

int count = 0;

for (Customer customer1 : customers) {

count++;

if (count == 25) {

System.out

.println(" ********************************************************************************** ");

count = 0;

}

System.out.println(customer1);

}

}

}

***************************************************************************************

cusotmer.java

public class Customer implements Comparable<Customer>{

String CustomerName;

int CustomerID;

double billBalance;

String EmailAddress;

String taxliability;

public String getCustomerName() {

return CustomerName;

}

public void setCustomerName(String customerName) {

CustomerName = customerName;

}

public int getCustomerID() {

return CustomerID;

}

public void setCustomerID(int customerID) {

CustomerID = customerID;

}

public double getBillBalance() {

return billBalance;

}

public void setBillBalance(double billBalance) {

this.billBalance = billBalance;

}

public String getEmailAddress() {

return EmailAddress;

}

public void setEmailAddress(String emailAddress) {

EmailAddress = emailAddress;

}

public String getTaxliability() {

return taxliability;

}

public void setTaxliability(String taxliability) {

this.taxliability = taxliability;

}

@Override

public String toString() {

return "Customer [CustomerName=" + CustomerName + ", CustomerID="

+ CustomerID + ", billBalance=" + billBalance

+ ", EmailAddress=" + EmailAddress + ", taxliability="

+ taxliability + "]";

}

@Override

public int hashCode() {

final int prime = 31;

int result = 1;

result = prime * result + CustomerID;

result = prime * result

+ ((CustomerName == null) ? 0 : CustomerName.hashCode());

result = prime * result

+ ((EmailAddress == null) ? 0 : EmailAddress.hashCode());

long temp;

temp = Double.doubleToLongBits(billBalance);

result = prime * result + (int) (temp ^ (temp >>> 32));

result = prime * result

+ ((taxliability == null) ? 0 : taxliability.hashCode());

return result;

}

@Override

public boolean equals(Object obj) {

if (this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

Customer other = (Customer) obj;

if (CustomerID != other.CustomerID)

return false;

if (CustomerName == null) {

if (other.CustomerName != null)

return false;

} else if (!CustomerName.equals(other.CustomerName))

return false;

if (EmailAddress == null) {

if (other.EmailAddress != null)

return false;

} else if (!EmailAddress.equals(other.EmailAddress))

return false;

if (Double.doubleToLongBits(billBalance) != Double

.doubleToLongBits(other.billBalance))

return false;

if (taxliability == null) {

if (other.taxliability != null)

return false;

} else if (!taxliability.equals(other.taxliability))

return false;

return true;

}

public Customer(String customerName, int customerID, double billBalance,

String emailAddress, String taxliability) {

CustomerName = customerName;

CustomerID = customerID;

this.billBalance = billBalance;

EmailAddress = emailAddress;

this.taxliability = taxliability;

}

@Override

public int compareTo(Customer customer) {

return this.CustomerID-customer.CustomerID;

}

}

*******************************************************************************

output

Reading the file using readLine() method:
Amazon 900 20000.00 purchasing@amazon.com 0.08
Rutgers 010 32000.00 purchasing@rutgers.edu education
Kean 001 158000.50 purchasing@kean.edu education
JoesInc 950 999999.00 purchasing@joesinc.com 0.03
TruckersInc 310 55000.00 purchasing@truckersinc.com 0.10
RedCross 849 48900.20 purchasing@redcross.org non-profit
CareBear 535 6000.00 purchasing@carebear.com 0.08
TiresInc 345 25000.00 purchasing@tires.com 0.07
Vassar 002 53000.00 purchasing@vassar.edu education
JCU 009 135678.50 purchasing@jcu.edu education
Avis 958 89999.00 purchasing@avis.com 0.03
Truckers2Corp 910 55000.00 purchasing@truckers2corp.com 0.10
TheFutureProject 853 48920.20 purchasing@tfp.org other
Thrifty 539 6600.00 purchasing@thrify.com 0.07
Prudential 660 28900.00 purchasing@prudential.com 0.07
Montclair 111 39800.00 purchasing@montclair.edu education
NJDOE 154 158000.50 purchasing@njdoe.gov other
Turtles 943 88888.00 purchasing@turtles.com 0.08
TruckersRus 610 54000.00 purchasing@truckersrus.com 0.08
MLH 823 900.20 purchasing@mlh.org other
PinkElephant 536 600.00 purchasing@pinkelephant.com 0.05
Uber 348 1500.00 purchasing@uber.com 0.05
Zales 213 54300.00 purchasing@zales.com 0.07
CheapCars 555 23210.00 purchasing@cheapcars.com 0.09
DAV 358 4860.20 purchasing@dav.org non-profit
ArthritisREU 238 4890.20 purchasing@arthritisreu.org other
BedBath 212 55000.00 purchasing@Bedbath.com 0.05
EnginesRus 522 23500.00 purchasing@enginesrus.com 0.06
TiresToGo 108 8300.00 purchasing@tirestogo.com 0.06
NorthEastern 798 40020.23 purchasing@northeastern.edu education
DunkinDonuts 819 2044.00 purchasing@dunkingdonuts.com 0.06
Beans 126 1000.50 purchasing@beans.com 0.03
PartyStore 334 500.50 purchasing@partystore.com 0.03
ColorsInc 218 2000.00 purchasing@colorsinc.com 0.06
BusinessRUs 531 1200.00 purchasing@businessrus.com 0.08
Business2 128 5300.00 purchasing@business2.com 0.02
Harvard 698 34020.23 purchasing@harvard.edu education
Jjill 829 2054.00 purchasing@jjill.com 0.05
Godiva 229 3100.50 purchasing@godiva.com 0.06
Macys 332 58200.50 purchasing@macys.com 0.07
Prudential 561 58290.00 purchasing@prudential.com 0.07
FoodPantry 579 25760.00 purchasing@foodpantry.org non-profit
StopandShop 377 8100.00 purchasing@stopandshop.com 0.06
FIT 907 30020.23 purchasing@fit.edu education
Office1 851 2044.00 purchasing@office1.com 0.05
Bakery1 727 4000.50 purchasing@bakery1.com 0.07
Google 003 500.50 purchasing@google.com 0.01
Census 155 102000.50 purchasing@census.gov other
CUNY 328 5500.00 purchasing@cuny.edu education
LegoInc 018 1978.50 purchasing@lego.com 0.02
Customer [CustomerName=Nordstrom, CustomerID=210, billBalance=50000.0, EmailAddress=purchasing@nordstrom.com, taxliability=0.07]
Customer [CustomerName=Alamo, CustomerID=520, billBalance=23000.0, EmailAddress=purchasing@alamo.com, taxliability=0.05]
Customer [CustomerName=Allied, CustomerID=100, billBalance=85300.0, EmailAddress=purchasing@allied.com, taxliability=0.06]
Customer [CustomerName=BostonU, CustomerID=697, billBalance=340020.23, EmailAddress=purchasing@tufts.edu, taxliability=education]
Customer [CustomerName=Clothiers, CustomerID=820, billBalance=20044.0, EmailAddress=purchasing@clothiers.com, taxliability=0.05]
Customer [CustomerName=ChocolateRus, CustomerID=125, billBalance=3000.5, EmailAddress=purchasing@chocolate.com, taxliability=0.1]
Customer [CustomerName=BalloonInc, CustomerID=331, billBalance=5100.5, EmailAddress=purchasing@balloon.com, taxliability=0.06]
Customer [CustomerName=JeweleryInc, CustomerID=211, billBalance=52000.0, EmailAddress=purchasing@jewelery.com, taxliability=0.08]
Customer [CustomerName=Hertz, CustomerID=521, billBalance=22200.0, EmailAddress=purchasing@hertz.com, taxliability=0.07]
Customer [CustomerName=Enterprise, CustomerID=120, billBalance=75300.0, EmailAddress=purchasing@enterprise.com, taxliability=0.06]
Customer [CustomerName=Tufts, CustomerID=699, billBalance=340020.23, EmailAddress=purchasing@tufts.edu, taxliability=education]
Customer [CustomerName=LandsEnd, CustomerID=825, billBalance=20054.0, EmailAddress=purchasing@landsend.com, taxliability=0.04]
Customer [CustomerName=Bromilows, CustomerID=225, billBalance=3300.5, EmailAddress=purchasing@bromilows.com, taxliability=0.5]
Customer [CustomerName=FlowersRus, CustomerID=339, billBalance=59300.5, EmailAddress=purchasing@flowers.com, taxliability=0.08]
Customer [CustomerName=MassMutual, CustomerID=567, billBalance=5890.0, EmailAddress=purchasing@massmutual.com, taxliability=0.08]
Customer [CustomerName=SaveTheChildren, CustomerID=578, billBalance=28760.0, EmailAddress=purchasing@savechildren.com, taxliability=non-profit]
Customer [CustomerName=ShopRite, CustomerID=333, billBalance=82100.0, EmailAddress=purchasing@shoprite.com, taxliability=0.07]
Customer [CustomerName=Brandeis, CustomerID=901, billBalance=340020.23, EmailAddress=purchasing@brandeis.edu, taxliability=education]
Customer [CustomerName=Clothier&Son, CustomerID=821, billBalance=20044.0, EmailAddress=purchasing@clothiersson.com, taxliability=0.05]
Customer [CustomerName=Calandras, CustomerID=725, billBalance=43000.5, EmailAddress=purchasing@calandra.com, taxliability=0.7]
Customer [CustomerName=Essie, CustomerID=338, billBalance=5000.5, EmailAddress=purchasing@essie.com, taxliability=0.07]
Customer [CustomerName=NYDOE, CustomerID=157, billBalance=12000.5, EmailAddress=purchasing@nydoe.gov, taxliability=other]
Customer [CustomerName=Columbia, CustomerID=322, billBalance=54500.0, EmailAddress=purchasing@columbia.edu, taxliability=education]
Customer [CustomerName=NJIT, CustomerID=99, billBalance=13978.5, EmailAddress=purchasing@NJIT.edu, taxliability=education]
**********************************************************************************
Customer [CustomerName=LLBean, CustomerID=852, billBalance=2234.0, EmailAddress=purchasing@llbean.com, taxliability=0.03]
Customer [CustomerName=Etsy, CustomerID=902, billBalance=20400.0, EmailAddress=purchasing@etsy.com, taxliability=0.03]
Customer [CustomerName=UPenn, CustomerID=11, billBalance=350000.0, EmailAddress=purchasing@upenn.edu, taxliability=education]
Customer [CustomerName=SetonHall, CustomerID=8, billBalance=158090.5, EmailAddress=purchasing@setonhall.edu, taxliability=education]
Customer [CustomerName=BillShop, CustomerID=956, billBalance=9999.0, EmailAddress=purchasing@billshop.com, taxliability=0.08]
Customer [CustomerName=Chocolatiers, CustomerID=318, billBalance=59000.0, EmailAddress=purchasing@chocolatiers.com, taxliability=0.03]
Customer [CustomerName=DiabetesOrg, CustomerID=850, billBalance=4900.2, EmailAddress=purchasing@diabetes.org, taxliability=non-profit]
Customer [CustomerName=BabyGap, CustomerID=538, billBalance=6100.0, EmailAddress=purchasing@babygap.com, taxliability=0.07]
Customer [CustomerName=Threads, CustomerID=349, billBalance=29000.0, EmailAddress=purchasing@threads.com, taxliability=0.05]
Customer [CustomerName=CountyCollege1, CustomerID=12, billBalance=5000.0, EmailAddress=purchasing@cc1.edu, taxliability=education]
Customer [CustomerName=CountyCollege2, CustomerID=109, billBalance=1678.5, EmailAddress=purchasing@cc2.edu, taxliability=education]
Customer [CustomerName=Oleander, CustomerID=959, billBalance=2999.0, EmailAddress=purchasing@oleander.com, taxliability=0.04]
Customer [CustomerName=TaxisInc, CustomerID=914, billBalance=5000.0, EmailAddress=purchasing@taxisinc.com, taxliability=0.09]
Customer [CustomerName=CSTA, CustomerID=859, billBalance=4820.2, EmailAddress=purchasing@csta.org, taxliability=other]
Customer [CustomerName=DryCleaners, CustomerID=540, billBalance=6800.0, EmailAddress=purchasing@drycleaners.com, taxliability=0.05]
Customer [CustomerName=CADOE, CustomerID=669, billBalance=2900.0, EmailAddress=purchasing@cadoe.gov.com, taxliability=other]
Customer [CustomerName=Linden, CustomerID=112, billBalance=3800.0, EmailAddress=purchasing@linden.gov, taxliability=other]
Customer [CustomerName=WADOE, CustomerID=159, billBalance=18000.5, EmailAddress=purchasing@wadoe.gov, taxliability=other]
Customer [CustomerName=WholeFoods, CustomerID=953, billBalance=8888.0, EmailAddress=purchasing@wholefoods.com, taxliability=0.06]
Customer [CustomerName=CarRental1, CustomerID=690, billBalance=5400.0, EmailAddress=purchasing@carrental1.com, taxliability=0.04]
Customer [CustomerName=CodeHS, CustomerID=822, billBalance=1000.2, EmailAddress=purchasing@codehs.org, taxliability=other]
Customer [CustomerName=BabyToys, CustomerID=539, billBalance=6000.0, EmailAddress=purchasing@babytoys.com, taxliability=0.04]
Customer [CustomerName=NYYankees, CustomerID=19, billBalance=15500.0, EmailAddress=purchasing@nyyankees.com, taxliability=0.07]
Customer [CustomerName=Fridays, CustomerID=110, billBalance=5300.0, EmailAddress=purchasing@fridays.com, taxliability=0.06]
Customer [CustomerName=CheapFood, CustomerID=551, billBalance=2210.0, EmailAddress=purchasing@cheapfood.com, taxliability=0.04]
**********************************************************************************
Customer [CustomerName=DAV2, CustomerID=359, billBalance=4860.2, EmailAddress=purchasing@dav2.org, taxliability=non-profit]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote