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 is 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 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 constructor should also assign 0 to the speed field. • accessor: the appropriate accessor methods should be implemented to access the values stored in the object's yearmodel, make, and speed fields. • accelerate: the accelerate method should add 5 to the speed field when 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 contains 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 print it on a separate line. then, call the brake method five times, each time printing the current speed of the car on a separate line. sample run java car 5↵ 10↵ 15↵ 20↵ 25↵ 20↵ 15↵ 10↵ 5↵ 0↵

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:10
Dean wants a quick way to look up staff members by their staff id. in cell q3, nest the existing vlookup function in an iferror function. if the vlookup function returns an error result, the text “invalid staff id” should be displayed by the formula. (hint: you can test that this formula is working by changing the value in cell q2 to 0, but remember to set the value of cell q2 back to 1036 when the testing is complete.)
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
Define a function printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. ex: printfeetinchshort(5, 8) prints: 5' 8"
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
The song about casey jones a railroad engineer who gives his life on the job would most likely gall under the folk song category of? a-work song b-nonsense song c-religious song d-ballad
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Where can page numbers appear? check all that apply. in the header inside tables in the footer at the bottom of columns at the top of columns
Answers: 1
You know the right answer?
Write a class named car that has the following fields: • yearmodel: the yearmodel field is an int...
Questions
question
Mathematics, 17.05.2021 19:40
question
History, 17.05.2021 19:40
question
Mathematics, 17.05.2021 19:40
question
Mathematics, 17.05.2021 19:40
question
Mathematics, 17.05.2021 19:40
Questions on the website: 13722363