Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Create an Automobile class for a dealership. Include fields for an ID number (id), make ( make), model ( model ), color (color ), year

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Create an Automobile class for a dealership. Include fields for an ID number (id), make ( make), model ( model ), color (color ), year ( year), and miles per gallon (mpg). Tasks Create the Automobile class. Add data fields to the Automobile class. Include get and set methods for each field. Do not allow the ID to be negative or more than 9999; if it is, set the ID to 0 . Do not allow the year to be earlier than 2005 or later than 2024 ; if it is, set the year to 0 . Do not allow the miles per gallon to be less than 10 or more than 60 , if it is, set the miles per gallon to 0. Define the get and set methods for the make data field. Define the get and set methods for the model data field. Define the get and set methods for the color data field. Define the get and set methods for the year data field. Define the get and set methods for the mpg data fieid: Include a default constructor that accepts no arguments and an overloaded constructor that. accepts arguments for each field value and uses the set methods to assign the values. Task Part B Write an application called Test Automobiles that declares two Automobile objects. Write a function called enterData() that prompts the user for the data values for an Automobile object and returns that object. When you test the program, be sure to enter some invalid data to demonstrate that all the methods work correctly. An example of the program is shown below: Enter ID (an integer) 12 Enter make Mercury Enter model Monterey Enter color Dark Blue Enter year (4 digits) 2007 Enter mpg 17 Enter ID (an integer) \$3 599 Enter make Pontiact Enter model 65 Enter year (4 digits) Enter mog 26 IOW12 Mercury Monterey Dark Blue 2007 Enter ID (an integer) 12 Enter make Mercury Enter model Monterey Enter color Dark Blue Enter year (4 digits )2007 Enter mpg 17 Enter ID (an integer) .599 Enter make Pontiac Enter model G5 Enter color White Enter year (4 digits) 2006 Enter mpg 25 IDH12 Mercury Monterey Dark Blue 200717.0 i IDH599 Pontiac G5 White 200625.0 miles per Tasks Create the TestAutomobiles class. Implement the enterData() function

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