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]
3 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]3 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]3 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
Write a c program to count the total number of commented characters and words in a c file taking both types of c file comments (
Tanzania [10]

#include<stdio.h>

#include<stdlib.h>

int comment1(FILE *fp)

{

   char ch;

   int count=0;

   while(fscanf(fp,"%c",&ch)!=EOF)

   {

       if(ch=='\n')

       {

           return count;

       }

       count++;

   }

   return count;

}

int comment2(FILE *fp)

{

   char ch;

   int count=0;

   while(fscanf(fp,"%c",&ch)!=EOF)

   {

       if(ch=='*')

       {

           fscanf(fp,"%c",&ch);

           if(ch=='/')

           {

               return count;

           }

           count++;

       }

       count++;

   }

   return 0;

}

int main()

{

   printf("Enter the file name:");

   char s[1000],ch,ch1;

   scanf("%s",s);

   FILE*fp;

   fp = fopen(s,"r");

   int count=0;

   while(fscanf(fp,"%c",&ch)!=EOF)

   {

       if(ch=='\"')

       {

           while(fscanf(fp,"%c",&ch)!=EOF)

           {

               if(ch=='\"')

               {

                   break;

               }

               if(ch=='\\')

               {

                   fscanf(fp,"%c",&ch);

               }

           }

       }

       else if(ch=='/')

       {

           fscanf(fp,"%c",&ch);

           if(ch=='/')

           {

               count += comment1(fp);

           }

           else if(ch=='*')

           {

               count += comment2(fp);

           }

       }

   }

   printf("%d\n",count);

   return 0;    

}

3 0
2 years ago
Read 2 more answers
Cathy designed a website for a cereal brand. When users view the website, their eyes first fall on the brand name, then they vie
PSYCHO15rus [73]

Answer:

dominance

Explanation:

i just took it and got it right

4 0
2 years ago
If the computer you are using is a laptop that moves from one network to another, you can click the _____ tab and configure stat
Leni [432]
If the computer you are using is a laptop that moves from one network to another, you can click the Alternate Configuration tab and configure a static IP address setting for a second network.
4 0
3 years ago
Which of the following solutions enables simultaneous digital transmission of voice, video, data, and other network services ove
Annette [7]

Answer:

3. ISDN

Explanation:

ISDN ( Integrated Services Digital Network  ) -

It is the used for the simultaneous digital transmission of network service , data , video and voice , instead of the old circuits of the public switched telephone network ( PSTN ) , is referred to as ISDN .

The characteristic feature of ISDN is that it integrates the data and speech on the same lines , which is not possible in PSTN .

Hence, from the given information of the question,

The correct option is ISDN .

8 0
2 years ago
Why is it preferable to code web pages in html format?
Ronch [10]
Depends on what you are working on.

If you are working on a website I recommend Adobe Dreamweaver CC.

if its small assignments that doesnt involve major work, I'd use something like notepad++
8 0
3 years ago
Read 2 more answers
Other questions:
  • Electronic ledger that tracks mathematical data
    15·1 answer
  • . Reorder the following efficiencies from smallest to largest:
    9·1 answer
  • You receive an email from someone who claims to be a representative from your credit card company. The email asks you to click o
    8·2 answers
  • assume that you want to sort an array have 100000 elements which algorithm (insert sort algorithm or quick sort algorithm) is th
    12·1 answer
  • How fast is a backwards long jump in Super Mario 64?
    7·1 answer
  • Which shortcut key aligns text to the center of the paige
    5·1 answer
  • A researcher plans to identify each participant in a certain medical experiment with a code consisting of either a single letter
    10·1 answer
  • In a Java Script language. create a two-dimension array consisting of numbers representing costs. After creating the array, prin
    11·1 answer
  • What is a computer modem?​
    9·1 answer
  • Assignment 1:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!