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
What types of storage can be used to access your data on another computer?
Ivenika [448]
<span>You could use cloud storage. Basically, the things you save are actually saved on another computer, that is, on another server, that is used as a hard drive for many pcs. You can access the cloud storage if you have internet and it works like a normal hard drive. There are even laptops that don't have storage other than cloud storage.</span>
6 0
3 years ago
Identify 5 internal and external hardware components of a server
UNO [17]

Answer:

Internal:

#CPU; That retrieves &execute instructions.

#Modem; Modulates& demodulates electric signals.

#RAM;Gives application a place to store &access data on a short time periods.

External:

#Mouse; Transmits commands and controlling movements.

#Moniter; Device used to display video output from computer.

#Printer; Accepts text, graphics to the paper.

Explanation:

Hope this will help you.

5 0
2 years ago
Pls awnser I will mark brainliest as soon as possible
german
What are the multiple choice answers?
6 0
2 years ago
Read 2 more answers
If you enter 234.567 into a cell that is formatted to display 1 decimal point place, what is the value stored in the cell
zalisa [80]

IT WILL NOT BE 234.6 FOR PF GANG JUST TOOK THE TEST

6 0
3 years ago
Clicking on the sheet tab with the _______ adds another worksheet to an Excel file.
alekssr [168]
Circled plus sign adds another worksheet
7 0
3 years ago
Other questions:
  • You just turned on a four port Ethernet switch (it hasn’t learned any addresses yet) and connected a host to each port. You send
    8·1 answer
  • In GamePoints' constructor, assign teamWhales with 500 and teamLions with 500. #include using namespace std; class GamePoints {
    13·1 answer
  • Which of the following could be defined as a general-purpose computing device that enables workers to create, manage, store, sea
    12·1 answer
  • Which is a good plan for backing up data?
    6·1 answer
  • write a program that calculates the total grade for N classroom exerices as a perfentage. the user should input the value for N
    11·1 answer
  • What is the simplest way to permanantly get rid of an unwanted file
    14·1 answer
  • What is wrong with my code...
    9·1 answer
  • 1. Insert a Header that has the following in excel​
    14·1 answer
  • WILL MARK BRAINLIEST FOR ANYONES ANSWER!
    12·1 answer
  • What are some innovations that television has undergone since its original invention ?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!