Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Output sample Write this program in Java chains - 13,728 chains - 1,004 exec-maven-plugins 3.0.0 exec (default-cli) solutions --- All companies in reverse order ---

Output sampleimage text in transcribedimage text in transcribedimage text in transcribed

Write this program in Java

chains - 13,728 chains - 1,004 exec-maven-plugins 3.0.0 exec (default-cli) solutions --- All companies in reverse order --- Toyota (84 yrs) Japan cars/employee - 28.18 K Renault (122 yrs) France cars/employee - 26.77 K Fizza Hut (63 yrs) USA Krispy Kreme (84 yrs) USA Ford (118 yrs) USA cars/employee - 32.67 K Coco Ichibanya (39 yrs) Japan Cafe de Coral (53 yrs) Hong Kong Cafe Amazon (19 yrs) Thailand Bonchon Chicken (19 yrs) South Korea BMW (105 yrs) Germany cars/employee - 20.77 K chains - 1,321 chains - 580 chains 2,009 chains - 281 --- Only automobile companies --- BA (105 yrs) Germany Ford (118 yrs) USA Renault (122 yrs) France Toyota (84 yrs) Japan cars/employee - 20.77 K cars/employee - 32.67 K cars/employee - 26.77 K cars/employee - 28.18 K Only fast food companies --- Bonchon Chicken ( 19 yes) South Korea Cafe Amazon (19 yrs) Thailand Cafe de Coral (53 yrs) Hong Kong Coco Ichibanya (39 yrs) Japan Krispy Kreme (84 yrs) USA Pizza Hut (63 yrs) USA chains - 281 chains - 2,009 chains - 580 chains - 1, 322 chains - 1,004 chains - 13,728 BUILD SUCCESS 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

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions