Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This section will count for 70% of Test 3's grade. a. (100pts) Write a program to define a class Car according to the following

image text in transcribed

This section will count for 70% of Test 3's grade. a. (100pts) Write a program to define a class Car according to the following UML. Please note that this is only a definition class, so there is no main method in the class. name: String mileage: int - isManual: boolean Car - carAmount: int //Increments by 1 when a new Car is created + Car (name: String, mileage: int, isManual: boolean) + getName(): String + setName (name: String): void + getMileage (): int + setMileage (mileage: int): void + isManual (): boolean + setIsManual (is: boolean): void + getCarAmount(): int b. (100pts) Based on the Car class, write a program named CarTest that completes the following tasks. Create an array with 3 Car objects. Use a for loop to initialize the array using user's inputs for name, mileage and whether the car has a manual transmission for each car. (Hint: use input.nextLine () to receive user's input for car name because car names could consist of more than one word.) Use a for loop to display the cars' names and their mileages in a table format. Use a for loop to calculate the average mileage of all cars. Display the average mileage of the cars. Display how many cars there exists using the getCarAmount () method. A sample execution of the CarTest program is given below: Please enter the car's name: Honda Civic Please enter the car's mileage: 61000 Please enter whether the car is manual (true/false): false Please enter the car's name: Ford Bronco Please enter the car's mileage: 11000 Please enter whether the car is manual (true/false): true Please enter the car's name: Toyota Corolla Please enter the car's mileage: 39000 Please enter whether the car is manual (true/false): false Car Mileage Honda Civic | 61000 Ford Bronco | 11000 Toyota Corolla | 39000 The average mileage of all cars is 37000.0 The amount of cars that exist is 3.

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

Applied Regression Analysis And Other Multivariable Methods

Authors: David G. Kleinbaum, Lawrence L. Kupper, Azhar Nizam, Eli S. Rosenberg

5th Edition

1285051084, 978-1285963754, 128596375X, 978-1285051086

More Books

Students also viewed these Programming questions