Computers and Technology

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↵

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 16:00, melinalange48
Choice of type is influenced primarily by these two factors?
Answers: 3
image
Computers and Technology, 22.06.2019 15:30, DestinyK8033
Why would a programmer use the logical operator and in an if statement? a: when an action is to be taken that requires both conditions to be falseb: when an action is to be taken that requires both conditions to be truec: when an action is to be taken that requires the first condition to be falsed: when an action is to be taken that requires the second condition to be truei took the test and the answer is b.
Answers: 3
image
Computers and Technology, 24.06.2019 07:40, daebreonnakelly
What type of multimedia are live news feeds? live news feeds are examples of multimedia.
Answers: 2
image
Computers and Technology, 24.06.2019 16:50, bella7524
7.23 main lab 7 - online shopping cart background this main lab extends the earlier prep lab "online shopping cart part 1". (you should save this as a separate project from the earlier prep lab). you will create an on-line shopping cart like you might use for your on-line purchases. the goal is to become comfortable with setting up classes and using objects. requirements this lab can be done individually or as pair programming. expanded itemtopurchase class (15 points) extend the itemtopurchase class as follows. we will not do unit testing in this lab so we will not be giving you the names of the member functions. create good ones on your own. create a parameterized constructor to assign item name, item description, item price, and item quantity (default values of "none" for name and description, and 0 for price and quantity). additional public member functions set an item description get an item description print the cost of an item - outputs the item name followed by the quantity, price, and subtotal (see example) print the description of an item - outputs the item name and description (see example) additional private data members a string for the description of the item. example output of the function which prints the cost of an item: bottled water 10 @ $1.50 = $15.00 example output of the function which prints the item description:
Answers: 1
Do you know the correct answer?
Write a class named car that has the following fields: • yearmodel: the yearmodel field is an int...

Questions in other subjects: