Question

6. A car dealership needs a program to store information about the cars for sale. For...

6. A car dealership needs a program to store information about the cars for sale. For each car, they want to keep track of the following information: number of doors (2 or 4), whether the car has air conditioning, and its average number of miles per gallon. Which of the following is the best design? (a) Use one class, Car, which has three data fields: int numDoors, boolean hasAir, and double milesPerGallon. (b) Use four unrelated classes: Car, Doors, AirConditioning, and MilesPerGallon. (c) Use a class Car which has three subclasses: Doors, AirConditioning, and MilesPerGallon. (d) Use a class Car, which has a subclass Doors, with a subclass AirConditioning, with a subclass MilesPerGallon. (e) Use three classes: Doors, AirConditioning, and MilesPerGallon, each with a subclass Car.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

Use one class, Car, with three data fields:
int numDoors, boolean hasAir, and double milesPerGallon

\;\;

Add a comment
Know the answer?
Add Answer to:
6. A car dealership needs a program to store information about the cars for sale. For...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A used-car dealership has hired you to modify the price of cars that are up for...

    A used-car dealership has hired you to modify the price of cars that are up for sale. In a script, assign the initial information about the car to a structure called carInfo. The structure shall have the following fields: ID: An identification number for the vehicle Make: A string that represents the make of the car Year: A number that corresponds to the year of the car Price: A number that holds the marked price of the car Miles: The...

  • For the 100 cars on the lot of a used-car dealership, would you expect a positive...

    For the 100 cars on the lot of a used-car dealership, would you expect a positive association, negative association, or no association between each of the following pairs of variables? The age of the car and the number of miles on the odometer Opositive association Onegative association no association The age of the car and the resale value Opositive association negative association no association The age of the car and the total amount that has been spent on repairs. Opositive...

  • Below are the Car class and Dealership class that I created In the previous lab import...

    Below are the Car class and Dealership class that I created In the previous lab import java.util.ArrayList; class Car { private String make; private String model; private int year; private double transmission; private int seats; private int maxSpeed; private int wheels; private String type; public Car() { } public Car(String make, String model, int year, double transmission, int seats, int maxSpeed, int wheels, String type) { this.make = make; this.model = model; this.year = year; this.transmission = transmission; this.seats =...

  • Needs Help In Java Programming language Exceptional Cars Purpose To review interfaces and exception usage. Directions...

    Needs Help In Java Programming language Exceptional Cars Purpose To review interfaces and exception usage. Directions Your task is to write a class called Car. Your class should have the following fields and methods: private int position private boolean headlightsOn public Car() - a constructor which initializes position to 0 and headlightsOn to false public Car(int position) - a constructor which initializes position to the passed in value and headlightsOn to false, and it should throw a NegativeNumberException with a...

  • Wolfie's Car Repair Shop For this assignment you will be completing a program that manages cars...

    Wolfie's Car Repair Shop For this assignment you will be completing a program that manages cars and car repairs at Wolfie's Car Repair Shop. The program is menu-driven. The menu can be found in Homework.Driver.java. Provided in that file is a series of methods that begin with the prefix main_. Those methods request input from the user and then call methods from the class CarRepairShop. It is these methods in the CarRepairShop that you will be implementing for homework. In...

  • Use BlueJ to write a program that reads a sequence of data for several car objects...

    Use BlueJ to write a program that reads a sequence of data for several car objects from an input file. It stores the data in an ArrayList<Car> list . Program should work for input file containing info for any number of cars. (You should not assume that it will always be seven lines in the input file). Use notepad to create input file "inData.txt". File should be stored in the same folder where all files from BlueJ for this program...

  • Purpose Demonstrate the ability to create and use subclasses and inheritance. This includes overriding method behaviors...

    Purpose Demonstrate the ability to create and use subclasses and inheritance. This includes overriding method behaviors and using polymorphism. Assignment Create an Aircraft class that has several properties that are common to all aircraft (Ex: number of engines, seat capacity). You define the name of the Class and the actual fields. The fields MUST BE PRIVATE!!! You must define a constructor that allows you to provide at least some of the field values used for an aircraft. You must define...

  • Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define...

    Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...

  • A liter is 0.264179 gallons. Write a program that will read in the number of liters...

    A liter is 0.264179 gallons. Write a program that will read in the number of liters of gasoline consumed by the user's car and the number of miles per gallon the car delivered. Your program should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the number of miles per gallon. Your program should use a globally defined constant for the number of liters per gallon. After doing this... Modify your...

  • Problem You work for a dealership that deals in all kinds of vehicles. Cars, Trucks, Boats,...

    Problem You work for a dealership that deals in all kinds of vehicles. Cars, Trucks, Boats, and so forth need to be inventoried in the system. The inventory must be detailed so that it could be searched based on number of doors, engine type, color, and so on. This program will demonstrate the following: How to create a base class How to extend a based class to create new classes How to use derived classes Solving the Problem Step 1...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT