Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can I write a Java program that makes use of a Car class to do the following? Your program should do the following in

How can I write a Java program that makes use of a Car class to do the following?

Your program should do the following in the indicated order: 1. Have the user input a car model, integer miles-per-gallon, and real number tank capacity. 2. Echo the input values in a single sentence. Format the tank capacity with two digits to the right of the decimal place. 3. Create a Car object with the user-input values by invoking the appropriate constructor. 4. Output a sentence containing the current attributes of this Car object by invoking the appropriate Car instance method and outputting the result. 5. Repeat steps 1-4 to create a second Car object with a second set of user-input values, performing the same outputs as above. 6. Have the user input a single integer number of miles to drive the Cars. 7. Drive both Cars the user-input number of miles. 8. Output whether or not the first Car is out of gas. 9. Output whether or not the second Car is out of gas. 10. Output the model name of the Car with the higher MPG. 11. Fill-up the gas tanks of both Cars. 12. Output sentences containing the current attributes of both Cars.Run your program with the following inputs: car #1 model: Suburban car #1 miles-per-gallon: 16 car #1 tank capacity: 26.5 car #2 model: Metro car #2 miles-per-gallon: 45 car #2 tank capacity: 13 number of miles to drive: 500

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_2

Step: 3

blur-text-image_3

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago