Question: Program in java Creating an external Car class and driver CarDemo class. Alter the instructions for the CarDemo class to include two methods (getInputYear() that
Program in java
Creating an external Car class and driver CarDemo class. Alter the instructions for the CarDemo class to include two methods (getInputYear() that returns a year between 1940 and 2016 and getInputMake() that returns the make of the car and checks for an empty String).
Additional info:
Problem Statement:
Write a class named Car that has the following fields:
yearModel: The yearModel field is an int that holds the car's year model (input is entered by user)
make: The make fiels is a String object that holds the make of the car (input is entered by user)
speed: The speed fields is an int that holds the car's current speed
In addition, the class should have the following methods
Constructor: The constructor should accept the car's year model and make as arguments. These values
should be assigned to the object's yearModel and make fields. The constrictor should also
assign 0 (zero) to the speed field.
Appropriate accessor methods to get the values stored in an object's yearModel, make, and speed fields.
accelerate: The accelerate method should add 5 to the speed field each time it is called.
brake: The brake method should subtract 5 from the speed field each time it is called.
Demonstrate the class in a program that creates a Car object, and then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and display it. Then, call the brake method 5 times. After each call to the brake method, get the current speed of the car and display it.

of Car Class Enter the nake of the car Input error-enter a car nake nter the nake of the car: chevy nter the year of the cari 1808 Input error enter a yearbetween 1948 and 2816 Enter the year of the car: 2815 Model Year: 2815 Mak Speed chevy peed UP Car's speed: 5 enoCars speed: 18 Car's speed: 15 Car's speed: 28 Car s speed: 25 lou down Car's speed: 28 Car's speedi 15 Car's speed: 10 Cars speed: S Car's speed of the Road for Car Class Denonstration Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
