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, 22.06.2019 01:00
)a grad student comes up with the following algorithm to sort an array a[1..n] that works by first sorting the first 2/3rds of the array, then sorting the last 2/3rds of the (resulting) array, and finally sorting the first 2/3rds of the new array. 1: function g-sort(a, n) . takes as input an array of n numbers, a[1..n] 2: g-sort-recurse(a, 1, n) 3: end function 4: function g-sort-recurse(a, `, u) 5: if u ⒠` ≤ 0 then 6: return . 1 or fewer elements already sorted 7: else if u ⒠` = 1 then . 2 elements 8: if a[u] < a[`] then . swap values 9: temp ↠a[u] 10: a[u] ↠a[`] 11: a[`] ↠temp 12: end if 13: else . 3 or more elements 14: size ↠u ⒠` + 1 15: twothirds ↠d(2 ◠size)/3e 16: g-sort-recurse(a, `, ` + twothirds ⒠1) 17: g-sort-recurse(a, u ⒠twothirds + 1, u) 18: g-sort-recurse(a, `, ` + twothirds ⒠1) 19: end if 20: end function first (5 pts), prove that the algorithm correctly sorts the numbers in the array (in increasing order). after showing that it correctly sorts 1 and 2 element intervals, you may make the (incorrect) assumption that the number of elements being passed to g-sort-recurse is always a multiple of 3 to simplify the notation (and drop the floors/ceilings).
Answers: 3
question
Computers and Technology, 22.06.2019 05:30
Agood flowchart alludes to both the inputs and outputs you will need to receive and give to the user. true or false?
Answers: 3
question
Computers and Technology, 23.06.2019 16:10
What is the ooh? a. omaha occupation handbook b. online occupational c. occupations online d. occupational outlook handbook select the best answer from the choices provided
Answers: 3
question
Computers and Technology, 25.06.2019 01:00
Your computer will organize files into order. alphabetical chronological size no specific
Answers: 2
You know the right answer?
Write a class named Car that has the following fields:

yearModel: The yearModel field is...
Questions
question
Biology, 17.12.2019 01:31
question
English, 17.12.2019 01:31
question
Mathematics, 17.12.2019 01:31
question
Mathematics, 17.12.2019 01:31