Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help ASAP me with this JAVA program! and please do correct INDENTATION with NO COMMENTS! thank you! Using enum and array of objects Use

please help ASAP me with this JAVA program! and please do correct INDENTATION with NO COMMENTS! thank you!

Using enum and array of objects

Use the enumerated type of: enum CarType { PORCHE, FERRARI, JAGUAR, UNKNOWN }

And place it in its own file. Then make a Car class that has the following:

Make of CarType

Year, string or integer

Mileage of integer

Place in its own file like so:

porche

2010

51119

ferrari

2014

9182

porche

2015

3987

jaguar

2011

65123

Create a program that will have an array of four cars of Car class. Have it use a while loop to read in the information per car (use the enhanced switch to convert the string of the make into CarType dont forget about the phantom newline), allocate each Car object and put the information into that object. Then have a for loop go through the array, print the Car objects, and total the mileage. After the for loop ends, print the average mileage.

Sample run:

Honest Georges Used Sports Cars

Car 1 is a 2010 FERRARI with 51119 miles on it

Car 2 is a 2014 JAGUAR with 9182 miles on it

Average mileage is 32352.8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions