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
Which of the following statements are true?
AleksAgata [21]

Answer:

c. All of these

Explanation:

Generic code by replacing generic types with Object, or with with upper bounds.

The compiler has to insert type casts into code that results from translating generic types do not exist at the byte code level.

8 0
4 years ago
What is the difference between an html tag and an html element ​
ruslelena [56]

Answer:

In technical terms, the HTML element happens to the collectible of a start tag, an end tag, attributes of the tag and everything that comes in between the start tag and the end tag. And whereas the HTML tag happens to be the opening or the closing, that is used for marking the beginning of the end of an element.

Explanation:

Please check the answer section.

4 0
3 years ago
Read 2 more answers
Normalization works through a series of stages called normal forms. For most purposes in business database design, _____ stages
rusak2 [61]
I do believe it’s A.....
6 0
3 years ago
Read 2 more answers
(Convert milliseconds to hours, minutes, and seconds) Write a function that converts milliseconds to hours, minutes, and seconds
ivanzaharov [21]

Answer:

I am writing the Python program. Let me know if you want the program in some other programming language.

def convertMillis(millis):  #function to convert milliseconds to hrs,mins,secs

   remaining = millis  # stores the value of millis to convert

   hrs = 3600000  # milliseconds in hour

   mins = 60000  # milliseconds in a minute

   secs = 1000  #milliseconds in a second

   hours =remaining / hrs  #value of millis input by user divided by 360000

   remaining %= hrs  #mod of remaining by 3600000

   minutes = remaining / mins  # the value of remaining divided by 60000

   remaining %= mins  #mod of remaining by 60000

   seconds = remaining / secs  

#the value left in remaining variable is divided by 1000

   remaining %= secs  #mod of remaining by 1000

   print ("%d:%d:%d" % (hours, minutes, seconds))

#displays hours mins and seconds with colons in between

   

def main():  #main function to get input from user and call convertMillis() to #convert the input to hours minutes and seconds

   millis=input("Enter time in milliseconds ")  #prompts user to enter time

   millis = int(millis)  #converts user input value to integer

   convertMillis(millis)   #calls function to convert input to hrs mins secs

main() #calls main() function

Explanation:

The program is well explained in the comments mentioned with each line of code. The program has two functions convertMillis(millis) which converts an input value in milliseconds to hours, minutes and seconds using the formula given in the program, and main() function that takes input value from user and calls convertMillis(millis) for the conversion of that input. The program along with its output is attached in screenshot.

4 0
3 years ago
A free-frame list Select one: a. is a set of all frames that are used for stack and heap memory. b. is a set of all frames that
zhuklara [117]

Answer:

b. is a set of all frames that are currently unallocated to any process

Explanation:

The free frame list is the list that used for all kind of the frames that presently non-allocated to any kind or process

Therefore as per the given situation, the correct option is b as it fits to the current situation

Hence, all the other options are wrong

So, only option b is correct

The same is to be considered

7 0
3 years ago
Other questions:
  • Which of the following is another name for cinematographers? (Select all that apply). lighting specialists production manager di
    8·1 answer
  • Explain why much of social media marketing is trial and error.
    11·1 answer
  • A(n) sentinel is a special value that marks the end of a sequence of items.
    12·1 answer
  • Which directive is used when defining 64-bit IEEE long reals?
    7·1 answer
  • The shortcut key to access the spelling and grammar check is _____.
    11·2 answers
  • Which of the following statements about global variables is true? 1.A global variable is accessible only to the main function. 2
    13·1 answer
  • ______________ is a raw fact about a person or an object
    6·1 answer
  • 15. Select the correct answer.
    9·1 answer
  • Can someone plzzzzzzz help
    14·2 answers
  • Why should you avoid the use of sarcasm, clichés, and idioms in business<br> letters
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!