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]
2 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]2 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
What are the primary functions of motor oil? a. Reduce friction and prevent wear b. Keep engine surfaces clean c. Remove heat to
ryzh [129]

The answer is E: all of the above.

7 0
2 years ago
Question # 2
mezya [45]
To state the main idea of what you read in your own words
8 0
2 years ago
What is the value of creating recurring tasks?
scoundrel [369]

Answer:

✔️saves time spent manually creating multiple tasks

Explanation:

I did it on edge

4 0
2 years ago
Read 2 more answers
Generally, websites ending in .edu, .gov, and .org are less likely to be biased, or to show preference toward a certain financia
svetlana [45]

Answer:

True

Explanation:

Domain extensions always appear at the end of a website's address.

It's a means to categorise websites.

.edu domains are used for educational purposes

.gov are restricted to by government entities

.org is largely used by nonprofit websites.

While

.net is derived from the word network, indicating it was originally intended for organizations involved in networking technologies, such as Internet service providers and other infrastructure companies

.biz is intended for registration of domains to be used by businesses

The right domain extension adds credibility and memorability to your website by aligning it with a specific brand purpose.

8 0
3 years ago
Aye yo, how do I get rid of an already placed end crystal? I thought it looked cool to build in my minecraft survival house, and
SpyIntel [72]

Answer:

they can be removed safely if they're immersed in water first.

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the Multiple Source Test
    15·2 answers
  • Ooooooooooooooooooooooooooooh im blinded by the lightssssssssss
    11·1 answer
  • ________ is digital textual information that can be stored, manipulated, and transmitted by electronic devices.
    7·1 answer
  • Which is an example of a screenshot?
    7·2 answers
  • Plz help! 3 questions! 1.The ideal light to use is.... A.front light B.a combination of side and back light C.a combination of f
    10·1 answer
  • Which technology forms the foundation for cloud computing? forms the foundation for cloud computing.
    12·2 answers
  • In ____, data can move in both directions at the same time, such as with a telephone.
    11·1 answer
  • The lines that connect the points of a polygon are called: (1 point)
    6·2 answers
  • Consider the following code: def tryIt(b): for i in range(len(b)): b[i] = b[i] + 100 #***********MAIN************ x = [] x = [56
    8·1 answer
  • What is added to brining liquid to add flavour​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!