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
7x+ 2x = 14<br>want is (x)?​
KATRIN_1 [288]

Answer:

x = 14/9 = 1 5/9 = 1.5556

Explanation:

7x + 2x = 14

9x = 14

x = 14/9 = 1 5/9 = 1.556

4 0
3 years ago
All of the following are potential benefits of blogging except
Pachacha [2.7K]
C is the right answer
4 0
3 years ago
If I put a short clip from a copyrighted video to Facebook and make it only viewable to friends, is that illegal?
nirvana33 [79]
No thats not illegal, because it is a copyright. And this is not for school.XD
7 0
4 years ago
Add a clause for identifying the sibling relationship. The predicate on the left handside of the rule should be sibling(X, Y), s
jolli1 [7]

Answer:

following are the solution to this question:

Explanation:

For Siblings (X,Y);

Alice(X),

Edward(Y),

parent(Edward,Victoria,Albert) //Albert is the father F

parent(Alice,Victoria,Albert)  //Victoria is the Mother M

Therefore,

X is siblings of Y when;

X is the mother M and father is F, and  Y is the same mother and father as X does, and satisfing the given condition.

It can be written as the following prolog rule:

Siblings_of(X,Y):

parents(X,M,F)

parents(Y,M,F)

Siblings_of(X,Y): parents(X,M,F), parents(Y,M,F)

|? - sibling_of(alice,edward).

yes

|? - Sibling_of(alice,X).

X=Edward

|? - Sibling_of(alice,alice).

yes

5 0
3 years ago
Describe the effect of a pull up resistor
Vesna [10]
With a pull-up resistor, the input pin will read a high state when the button is not pressed. In other words, a small amount of current is flowing between VCC and the input pin (not to ground), thus the input pin reads close to VCC. When the button is pressed, it connects the input pin directly to ground.
3 0
4 years ago
Other questions:
  • Match each of the following terms to its function:_________
    13·1 answer
  • Assume that an int variable age has been declared and already given a value and assume that a char variable choice has been decl
    9·1 answer
  • Shania has started a new job as an app developer. Her first task was to make an old app designed for Android available on other
    9·1 answer
  • 1. Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address
    7·1 answer
  • It's safe to download files from the internet if u perform regular Windows security updates, that is all u need to protect your
    10·2 answers
  • ICD-10-CM diagnosis codes are entered in Block 21 of the CMS-1500 claim. A maximum of __________ ICD-10- CM codes may be entered
    14·1 answer
  • Marco had a database that showed the first, second, and third favorite ice cream flavors for each person in his school. He used
    11·2 answers
  • Which of the following is true for an API?
    6·1 answer
  • select the correct answer from each drop-down menu. “To clean a computer screen, use ___. To clean a keyboard, use a ___.”
    7·1 answer
  • Using programming libraries is one way of incorporating existing code into new programs.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!