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

ogramming Lab Examination: Office Supplies Inc Concepts: Classes and objects, in

ID: 3701680 • Letter: O

Question

ogramming Lab Examination: Office Supplies Inc Concepts: Classes and objects, inheritance, polymorphism ava The purpose of this project is to gi programming using classes and polymorphism in an application that involves arrays of objects and sorting arrays containing objects. You will write several classes for this lab exam. Please submit all classes coded along with the outputted report. Assignment: Office Supplies Inc., an office supply store, services many customers. As customers' orders for office supplies are shipped, information is entered into a file. 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 for each customer from the data in the text file. You must use the text file provided for the report. 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-tax- exempt. 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: rom the information provided, write a solution that includes the following: A suitable inheritance hierarchy that 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.. .

Explanation / Answer


import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class LabExam{
public int CustomerId;
public String CustomerName;
public String BillBalance;
public String EmailId;
public String Tax_liability;
public int getCustomerId() {
return CustomerId;
}
public void setCustomerId(int customerId) {
CustomerId = customerId;
}
public String getCustomerName() {
return CustomerName;
}
public void setCustomerName(String customerName) {
CustomerName = customerName;
}
public String getBillBalance() {
return BillBalance;
}
public void setBillBalance(String billBalance) {
BillBalance = billBalance;
}
public String getEmailId() {
return EmailId;
}
public void setEmailId(String emailId) {
EmailId = emailId;
}
public String getTax_liability() {
return Tax_liability;
}
public void setTax_liability(String tax_liability) {
Tax_liability = tax_liability;
}
public static void main(String[] args) throws FileNotFoundException {
File file = new File("C:\Users\chandramouli.MDC\Desktop\test.txt");
Scanner sc = new Scanner(file);
sc.useDelimiter("\Z");
ArrayList<String> animalData = new ArrayList<String>();
List<LabExam> LE = new ArrayList<LabExam>();
List<LabExam> LE1 = new ArrayList<LabExam>();
List<Integer> list2=new ArrayList<Integer>();
while (sc.hasNext()) {
String[] columns = sc.nextLine().split("/t");
String data = columns[columns.length-1];
animalData.add(data);

}
for(String val: animalData){
//System.out.println(val.split("\s"));
List<String> list1 = new ArrayList<String>();
for(String word:val.split("\s",0)){
list1.add(word);
}
LabExam labExam = new LabExam();
labExam.setCustomerName(list1.get(0));
labExam.setCustomerId(Integer.parseInt(list1.get(1)));
labExam.setBillBalance(list1.get(2));
labExam.setEmailId(list1.get(3));
labExam.setTax_liability(list1.get(4));
LE.add(labExam);
}
for(LabExam le : LE){
list2.add(le.getCustomerId());
}
Collections.sort(list2);
for(int val : list2){
for(LabExam le : LE){
if(val==le.getCustomerId()){
LE1.add(le);
}
}
}
System.out.println("Customer_Id"+" "+"Customer_Name"+" "+"BillBalance"+" "+"EmailId"+" "+"Tax_Liablity");
for(LabExam le : LE1){
System.out.println(le.getCustomerId()+" "+le.getCustomerName()+" "+le.getBillBalance()+" "+le.getEmailId()+" "+le.getTax_liability());
}
}
}


Note: please change the file location and run the class file...