Question: Write this program in java 1. Copy class Company to your source file **this class must not be changed class Company { protected String name,

 Write this program in java 1. Copy class Company to yoursource file **this class must not be changed class Company { protected

Write this program in java

1. Copy class Company to your source file **this class must not be changed class Company { protected String name, origin; protected int founded; public Company(String nm, String og, int fy) { name = nm; origin = og; founded = fy; } public void print() { /* override this in child class */ } } 2. Write classes Automobile, and Fastfood that extend Company o Automobile : add variables cars, employees, carperEmployee o FastFood : add variable chains o Other variables and methods can be added to these class 3. Write class Statistics that acts as the main class. In main method, 3.1 Create an array of 10 Company objects, e.g. Company [ ] Co 3.2 Read each line of input file into co[i]. For each line, the type of co[i] may be Automobile or Fast Food object depending on the input o Column 1 = type (A = Automobile, F = FastFood) o Column 2 = name o Column 3 = founded year o Column 4 = country of origin o Column 5 = #cars produced in millions (for Automobile) or #chains (for FastFood) o Column 6 = #employees in thousands (for Automobile) companies.txt A, BMW, 1916, Germany, 2.7, 130 F, Bonchon Chicken, 2002, South Korea, 281 F, Cafe Amazon, 2002, Thailand, 2009 F, Cafe de Coral, 1968, Hong Kong, 580 F, Coco Ichibanya, 1982, Japan, 1321 A, Ford, 1903, USA, 6.6, 202 F, Krispy Kreme, 1937, USA, 1004 F, Pizza Hut, 1958, USA, 13728 A, Renault, 1899, France, 3.4, 127 A, Toyota, 1937, Japan, 10.4, 369 3.3 Calculate the following o For both types of objects calculate age from founded year o For Automobile also calculate cars per employee (in thousands) 3.4 Print results of all Automobile/Fast Food in the reverse order of the input 3.5 Print results of only Automobile in the original order of the input 3.6 Print results of only FastFood in the original order of the input Note 1 Read the whole line into a string (e.g. str) and split at comma. Trim string before converting it to number String line scan.nextLine(); String [] buf = line.split(","); int year = Integer.parseInt(buf[2].trim()); = Note 2 To compare between 2 strings, use method equals or equalsIgnoreCase if (str.equals("A")) System.out.println("automobile"); if (str.equalsIgnoreCase("a")) System.out.println("automobile"); Note 3 To check type of object if (co[i] instanceof FastFood) System.out.println("fast food")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!