1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sloan [31]
3 years ago
6

Write a class named Car that has the following member variables: - yearModel. An int that holds the car’s year model. - make. A

string that holds the make of the car. - speed. An int that holds the car’s current speed. The class should have the following member functions: - Appropriate accessor functions to get the values stored in an object’s yearModel, make, and speed member variables. - accelerate function that adds 5 to the speed member variable each time it is called. - brake function that subtracts 5 from the speed member variable each time it is called.
Computers and Technology
1 answer:
Wewaii [24]3 years ago
6 0

Answer:

public class Car {

//Member variables    

private int yearModel;

   private String make;

   private int speed;

   //Constructor

   public Car(int yearModel, String make, int speed) {

       this.yearModel = yearModel;

       this.make = make;

       this.speed = speed;

   }

   //Accessor Methods getters and setters

   public int getYearModel() {

       return yearModel;

   }

   public void setYearModel(int yearModel) {

       this.yearModel = yearModel;

   }

   public String getMake() {

       return make;

   }

   public void setMake(String make) {

       this.make = make;

   }

   public int getSpeed() {

       return speed;

   }

   public void setSpeed(int speed) {

       this.speed = speed;

   }

   //Accelerate function

   public void accelerate(){

       this.speed+=5;

   }

   // Brake function

   public void brake(){

       this.speed-=5;

   }

}

Explanation:

  • As required by the question, The class Car is created using Java programming language
  • The members variables, the constructor, The accessor methods are all created as required by the question (Please pay attention to the comments added to the code)
  • The accelerate and brake functions that add and subtract 5 from the speed member variable respectively are also created.
You might be interested in
When is the bond between the actin and myosin head is broken? when an ATP molecule binds to the myosin head when an ATP molecule
Goshia [24]

Answer:

The answer is when an ATP molecule binds to the myosin head.

Explanation:

when an ATP molecule binds to the myosin head. The molecule basis for this interaction is the binding of myosin to actin filaments, allowing the binding ATP dissociates myosin from actin.

8 0
4 years ago
Antivirus software products require that you update _____ on a regular basis
horrorfan [7]
Operating System

Not much context for this questiom but that should be right.
7 0
3 years ago
Read 2 more answers
A bookstore owner wants to allow customers to pay for books using their mobile phones. Which version of iOS will support the boo
swat32
Answer is iOS 9 & Apple Pay
7 0
3 years ago
Read 2 more answers
With the Linux operating system, its open source design means it can be used, modified and ______
nadya68 [22]

Answer:

distributed.

Explanation:

Because Linux is released under an open source license, which prevents restrictions on the use of the software, anyone can run, study, modify, and redistribute the source code, or even sell copies of their modified code, as long as they do so under the same license.

3 0
3 years ago
An administrator has added a firewall within an Azure virtual network. What do we know for sure about the firewall?
slavikrds [6]

Answer:

its a host based firewall

Explanation:

because the administrator put it ntentionally and the only way do disable the firewall is by signing in as the admin (if you're the admin) and turn it off manualy

or if you're not the admin, ask them to do so.

5 0
3 years ago
Other questions:
  • The equation y=2x+1 represents a function true or false
    11·1 answer
  • Can you help please.
    11·1 answer
  • Two technicians are discussing amperage in a series circuit. Technician A states that adding resistors in series will decrease c
    13·1 answer
  • Given positive integer num_insects, write a while loop that prints that number doubled up to, but without exceeding 100. Follow
    8·1 answer
  • A ______ is a personal computer which stays in one location (e.g. office) due to its larger form factor.
    5·1 answer
  • Addition and subtraction are considered to be ____ operations performed by a computer.
    7·1 answer
  • Write a program that prompts the user to enter the center and a point on the circle. The program should then output the circle’s
    9·1 answer
  • Natalie is a secretary and must complete a large amount of filing this afternoon. At 1:00 PM, the office receptionist gets sick
    10·1 answer
  • Tricia is managing tasks that have been assigned to her. She needs to enter mileage information in relation to a project. Which
    5·1 answer
  • What are tasks performed by pascaline?​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!