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
The ____ of a variable is the location in memory where it’s value is stored. A. Value B. Address C. Data type D. Number
fomenos

Answer: C. Data type

Explanation:

data types are defined as the data storage format that a variable can store a data to perform a specific operation. Data types are used to define a variable before its use in a program. Size of variable, constant and array are determined by data types.

3 0
3 years ago
Hey all! Adobe here. I think that we should talk about After Effects 2021 and After Effects CC 2021. With BRAND NEW FEATURES, (A
ella [17]

Answer:

thx ur the best

7 0
2 years ago
Computers store temporary Internet files in the Recycle Bin. These files take up space and slow down a computer. Which tool can
poizon [28]
Empty the recycle bin.
6 0
3 years ago
Allie is working on the development of a web browser and wants to make sure that the browser correctly implements the Hypertext
Sophie [7]

Answer: World Wide Web Consortium (W3C)

Explanation:

World Wide Web Consortium(W3C) is known as the organization that establishes the standards and regulation for the World Wide Web(www).This platform is used for application development and setting the web guideline through which websites and web pages function.

  • According to the situation described in the question, Allie should concern with the World Wide Web Consortium (W3C) for getting the accurate and authentic information source.
  • Allie expects that browser developed by her should work perfectly along with HTML standards so W3C is the department for providing the correct guidelines and standards to any web browser.
6 0
3 years ago
The _________ causes a program to wait until information is typed at the keyboard and the enter key is pressed.
Komok [63]
All console programs have a way to prompt for input.

For C#, the answer is Console.ReadLine().
For C, the answer is a.o. fgets()
For C++, the answer could be cin >>
... and so on...

Not sure what answer you need here.
5 0
3 years ago
Other questions:
  • Overloading in methods are popular in programming, and why overloading is important.
    6·1 answer
  • Which of the following scenarios might indicate that you have been a victim of identity theft?A)Your credit report displays acco
    12·1 answer
  • What is the difference between keywords and identifiers in c++ ?
    5·1 answer
  • A(n) _____ measures the ability to juggle a variety of demands, as in a manager's job where the candidate is presented with simu
    8·1 answer
  • Moving Images are called________.
    15·1 answer
  • What does resolution mean on a computer monitor?
    9·2 answers
  • Brain for free 12628397
    14·2 answers
  • Write a java program that asks the student for his name and Favorite basketball team. The program should then welcome the studen
    11·2 answers
  • Data elements in a relational database are organized into ____
    15·1 answer
  • Why should we learn Ethereum? Explain.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!