subject

Write a class named Car that has the following fields:

yearModel: The yearModel field is an int that holds the car’s year model.

make: The make field references a String object that holds the make of the car.

speed: The speed field is an int that holds the car’s current speed.

In addition, the class should have the following constructor and other methods:

Constructors: One constructor should accept the car's year model, make, and speed as arguments. These values should be assigned to the object's yearModel, make, and speed fields. Another constructor will have no arguments and will assign 0 as the car's year model and speed and an empty string ("") as the make.

Accessors: Appropriate accessor methods should get the values stored in an object's yearModel, make, and speed fields.

Mutators: Appropriate mutator methods should store values 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 asks the user to input data and then creates a Car object. It 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 five times. After each call to the brake method, get the current speed of the car and display it.

The output from running this program will appear similar to:

Enter the car's year model: 1965
Enter the car's make: Mustang
Enter the car's speed: 30

Current status of the car:
Year model: 1965
Make: Mustang
Speed: 30

Accelerating...
Now the speed is 35

Accelerating...
Now the speed is 40

Accelerating...
Now the speed is 45

Accelerating...
Now the speed is 50

Accelerating...
Now the speed is 55

Braking...
Now the speed is 50

Braking...
Now the speed is 45

Braking...
Now the speed is 40

Braking...
Now the speed is 35

Braking...
Now the spee

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 14:10
In a flashdisk wich icon can you use to open files in computer
Answers: 1
question
Computers and Technology, 22.06.2019 11:30
Awell-diversified portfolio needs about 20-25 stocks from different categories is this true or false?
Answers: 2
question
Computers and Technology, 22.06.2019 14:30
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
You know the right answer?
Write a class named Car that has the following fields:

yearModel: The yearModel field is...
Questions
question
Mathematics, 22.04.2020 16:29
question
History, 22.04.2020 16:29
question
Chemistry, 22.04.2020 16:29
question
Biology, 22.04.2020 16:29
Questions on the website: 13722360