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
Paraphin [41]
4 years ago
6

Write a class named Car that has the following fields: yearMode1. The yearModel field is an int that holds the car's year model.

make. The make field is a String object that holds the make of the car, such as "Ford" "Chevrolet", "Honda", etc. speed. The speed field is an int that holds the car's current speed. In addition, the class should have the following methods . Constructor. The constructor should accept the car's year model and make as ments. These values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. Accessor. The appropriate accessor methods get the values stored in an object's yearModel, make, and speed fields. , accelerate. The accelerate method should add 5 to the speed field each time it is called _________. brake. The brake method should subtract 5 from the speed field each time it is called.
Computers and Technology
2 answers:
Gekata [30.6K]4 years ago
8 0
Skeh wkf ahfmroztdjdy
Dmgk
Ann Write a class named Car that has the following fields: yearMode1. The yearModel field is an int that holds the car's year model. make. The make field is a String object that holds the make of the car, such as "Ford" "Chevrolet", "Honda", etc. speed. The speed field is an int that holds the car's current speed. In addition, the class should have the following methods . Constructor. The constructor should accept the car's year model and make as ments. These values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. Accessor. The appropriate accessor methods get the values stored in an object's yearModel, make, and speed fields. , accelerate. The accelerate method should add 5 to the speed field each time it is called _________. brake. The brake method should subtract 5 from the speed field each time it is called.
Harlamova29_29 [7]4 years ago
8 0
<h2>Answer:</h2>

//Write the class definition for the class Car

public class Car {

   //Declare the instance variables(fields)

   int yearModel;

   String make;

   int speed;

   

   //Declare the constructor: Make sure the constructor has  

   //the same name as the name of the class - Car.

   //The constructor receives two parameters - yearModel and make.

   //The parameters are then assigned to their respective fields.

   //The speed field is given a value of zero.

   public Car(int yearModel, String make){

       this.yearModel = yearModel;

       this.make = make;

       this.speed = 0;

   }

   //Accessor method - get - for the yearModel

   //returns the yearModel of the car

   public int getYearModel() {

       return yearModel;

   }

   //Accessor method - get - for the make

   //returns the make of the car

   public String getMake() {

       return make;

   }

   //Accessor method - get- for the speed

   //returns the speed of the car

   public int getSpeed() {

       return speed;

   }

   

   //Method accelerate() to increase the speed of the car by 5

   //each time it is called

   public void accelerate(){

       this.speed += 5;

   }

   

   //Method brake() to decrease the speed of the car by 5

   //each time it is called

   public void brake(){

       this.speed -= 5;

   }

   

}    //End of class declaration

<h2>Explanation:</h2>

The code above has been written in Java. It contains comments explaining the code. Please go through the comments. The actual lines of code that are executable are written in bold-face to distinguish them from the comments.

You might be interested in
In what year did the first ibm personal computer debut
m_a_m_a [10]

Answer:

IBM's own Personal Computer (IBM 5150) was introduced in August 1981, only a year after corporate executives gave the go-ahead to Bill Lowe, the lab director in the company's Boca Raton, Fla., facilities. He set up a task force that developed the proposal for the first IBM PC.

4 0
3 years ago
Effective online learning method for students
qwelly [4]

Answer: Desire method: This is one of the unique but most effective teaching strategies to grab student attention and...

Active learning: The one sided lecture methods are no more fruitful to get the interest of the new generation...

Cooperative learning: Give them a chance to come out of their seats

Explanation:

4 0
3 years ago
What does usb stand for
e-lub [12.9K]
Universal Serial Bus
8 0
3 years ago
Read 2 more answers
What is pseudocode? O A way of describing a set of instructions in text form using plain english O A diagrammatic representation
Marat540 [252]

The definition of pseudocode is that; A: A way of describing a set of instructions in text form using plain English

<h3>What is Pseudocode? </h3>

In computer science, pseudocode is defined as a plain language description of the steps in an algorithm or another system.

Now, the way Pseudocode works is that it often makes use of structural conventions of a normal programming language to be utilized for human reading instead of machine reading.

Pseudocode usually omits details that are essential for machine understanding of the algorithm, such as variable declarations and language-specific code.

Read more about Pseudocode at; brainly.com/question/11623795

8 0
3 years ago
Question 1(Multiple Choice Worth 5 points)
aleksley [76]

Answer:

b

Explanation:

it's not a c or d and now I have to make it 20 characters long so I will do this

3 0
3 years ago
Read 2 more answers
Other questions:
  • Effective resource management: a. Locks out unauthorized access and can work to prevent changes to resources by internal users n
    8·1 answer
  • Write a loop that prints each country's population in country_pop. Sample output with input:
    7·1 answer
  • Linux is a kind of software whose code is provided for use, modification, and redistribution. what kind of software is this?
    5·1 answer
  • Why am I not getting the activation link for my account?
    11·1 answer
  • Which file is usually the first file to be displayed when you navigate to a website?
    7·1 answer
  • If an image has only 4 colors, how many bits are necessary to represent one pixel’s color? Describe a new custom encoding that u
    8·1 answer
  • Write a function in Java to implement the following logic:
    13·1 answer
  • ____ is an easy way to invitation through a web page​
    13·1 answer
  • The number of binary digits required to count 10010 is called _________​
    10·1 answer
  • Bad Directions You are driving to your friend’s house and are using your smartphone for directions. While approaching your desti
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!