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
BARSIC [14]
3 years ago
11

This needs to be written in Java.

Computers and Technology
1 answer:
Slav-nsk [51]3 years ago
5 0

Answer:

Here is Automobile.java

class Automobile {   //class name

   private int ID, year, milesPerGallon, speed = 0;   // private member variables of Automobile of int type

   private String model, vinNo, make, color;   // private member variables of Automobile of String type

   public void setID(int ID){   //mutator method to set ID

      if (ID >= 0 && ID <= 9999)  // checks ID should not be negative or more than 9999

      this.ID = ID;  

     else this.ID = 0;  }  //if ID is negative or greater than 9999 then set ID to 0

   public void setModel(String model){  // mutator method to set model

       this.model = model;      }  

   public void setYear(int year){// mutator method to set year

      if (year >= 2000 && year <= 2017) //checks that year should not be earlier than 2000 or later than 2017

         this.ID = ID;

       else this.year = 0;     } //if year is less than 2000 or greater than 2017 then set year to 0

   public void setVinNo(String vinNo){  //mutator method to set vin number

       this.vinNo = vinNo;      }

   public void setMilesPerGalon(int milesPerGallon){  //mutator method to set miles per gallon

      if (milesPerGallon >= 10 && year <= 60)  //checks that miles per gallon should not be less than 10 or more than 60

          this.milesPerGallon = milesPerGallon;

      else this.milesPerGallon = 0;      } //if it is more than 60 or less than 10 then set miles per gallon to 0

   public void setSpeed(int speed){ //mutator method to set speed

       this.speed = speed;      }

   public void setMake(String make){  //mutator method to set make

       this.make = make;    }

   public void setColor(String color){  //mutator method to set color

       this.color = color;    }

   public int getID() //accessor method to get or access ID

   {return ID;} //returns the current ID

   public String getModel() //accessor method to get or access model

   {return model;} //returns the current model

   public int getYear()// accessor method to get or access year

   {return year;} //returns the current year

   public String getVinNo() // accessor method to get or access vin number

   {return vinNo;} //returns the current vin number

   public int getMilesPerGallon() //accessor method to get or access miles per gallon

   {return milesPerGallon;} //returns the current miles per gallon

   public int getSpeed() //accessor method to get or access speed

   {return speed;} //returns the current speed

   public String getMake() //accessor method to get or access make

   {return make;} //returns the current make

   public String getColor() //accessor method to get or access color

   {return color;}    //returns the current color

  public int Accelerate() {  //method that increase speed by 5

      setSpeed(speed + 5); //calls set speed to add 5 to the speed field

      return speed;    } //returns the speed after increasing 5

  public int Brake() { //method that decreases speed by 5

      setSpeed(speed - 5);//calls set speed to subtract 5 from the speed field

      return speed;    } //returns the speed after decreasing 5

  public int Accelerate(int spd) {  //overloading methods for Accelerate()that accepts a single parameter spd

      setSpeed(speed + spd);  //increases speed up to specified value of spd

      return speed;    }

  public int Brake(int spd) {  //overloading methods for Brake()that accepts a single parameter spd

      setSpeed(speed - spd); //decreases speed up to specified value of spd

      return speed;    }

   public Automobile(int ID, String make, String model, int year, String vinNo, int milesPerGallon, int speed, String color){  //constructor  that accepts arguments for each field value and uses the set methods to assign the values

      setID(ID);  

      setModel(model);  

      setYear(year);  

      setVinNo(vinNo);

      setMilesPerGalon(milesPerGallon);  

      setSpeed(speed);  

      setMake(make);  

      setColor(color);      } }

Explanation:

Here is TestAutomobiles.java

public class TestAutomobiles {   //class name

  public static void main(String args[]) {  //start of main method

    Automobile auto = new Automobile(123, "ABC", "XYZ", 2010, "MMM", 30, 150, "White");   //creates an object of Automobile class and calls its constructor passing the values for each of the fields

 System.out.println("Initial Speed: " + auto.getSpeed());  //calls getSpeed method to get the current speed using object auto. The current speed is 150

 System.out.println("Speed after applying acceleration: " + auto.Accelerate());   //calls Accelerate() method to increase the current speed to 5

 System.out.println("Speed after applying brake: " + auto.Brake());  //calls Brake() method to decrease the current speed to 5

   System.out.println("Speed after applying acceleration: " + auto.Accelerate(180));  //calls overloading Accelerate() method to increase the current speed to 180

     System.out.println("Speed after applying brake: " + auto.Brake(50));     }  } //calls overloading Brake() method to decrease the current speed to 50

//The screenshot of the output of the program is attached.

You might be interested in
.2. What approach to deviance do you find most persuasive: that
garik1379 [7]

Answer:

The description for the given question is described in the explanation section below.

Explanation:

Since deviance constitutes a breach of a people's current standard. I believe Erickson's psychological concept that Deviance becomes a trait that is commonly considered to need social control agencies' intervention, i.e. 'Something must being done'.

  • There most probably resulted whenever the rules governing behavior appear inconsistent in just about any particular frame.
  • Therefore the principle of this theory is that even in the analysis of deviance this same significant point seems to be the social community, instead of the participant.
8 0
3 years ago
Which best describe a resource each student could use to find information
marta [7]

Online library resources

Explanation

Students can utilize online library resources from various campus available for online educational uses.In the library, information on current research in the various displines can be obtained through a search on the book, journal or document.In addition to that, goggle offers academic journals and academic documents prepared by scholars for other academicians to read and get information.

8 0
3 years ago
Read 2 more answers
What will be the results of executing the following statements? x.setEditable(true); x.setText("Tiny Tim"); a. The text field x
maxonik [38]

Answer:

Option B: The text field x will have the value "Tiny Tim" and the user will be able to change its value.

Explanation:

  • The first statement say:  x.setEditable(true);

It will only change the property of the text present in x to editable. This means that whenever the text value needs to change the user can edit it.

  • The second statement say:   x.setText("Tiny Tim");

It will put the text "Tiny Tim" into the attribute x and present it as the output or result.

6 0
3 years ago
A characteristic of a 3D model that a 2D model does not have is:
Bas_tet [7]

Answer:

Volume

Explanation:

A characteristic of a 3D model that a 2D model does not have is:

<em>Volume</em>

<em>PLEASE</em><em> </em><em>DO MARK</em><em> </em><em>ME AS</em><em> </em><em>BRAINLIEST UWU</em><em> </em>

3 0
2 years ago
What is required to display content on transparencies?
VladimirAG [237]
An overhead projector is required to display content on transparencies. A transparency is a thin sheet of plastic in which light is reflected upon to display content.The light source emits light towards the transparency and then the image is displayed on the wall. Usually, this light source comes from below and lights upward and so the content is depicted above or overhead.
6 0
2 years ago
Other questions:
  • The major difference between a calculator and a computer, when performing calculations, is that a
    10·1 answer
  • The RESET circuit used on the four 3-Bit Counters analyzed in this activity reset the counts to zero (000). It makes sense for t
    14·1 answer
  • Write a function called activity which takes an integer parameter X that does the following:
    6·1 answer
  • Convert 15 from decimal to binary. Show your work.
    14·1 answer
  • Suppose end system A wants to send a large file to end system B. At a very high level, describe how end system A creates packets
    7·1 answer
  • How do the principles behind the Agile Manifesto suggest approaching architecture?A. Architecture emergesB. Architecture is not
    10·1 answer
  • Describe the different non-printing characters,​
    11·1 answer
  • Gold jewellery is made when solid-gold is melted and then put into containers which are the shape of the jewellery. After this t
    9·1 answer
  • State three advantages of using a printer​
    15·1 answer
  • - O conhecimento na Educação Física, normalmente passa do senso comum e vai para um conhecimento mais formal, ou seja, do conhec
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!