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
Anna is making a presentation on the top five most visited cities in her state. she wants to make sure that she does not put in
andrey2020 [161]
Outline View. This view shows only the text of all the slides in the presentation on the left pane, enabling Anna to see whether she has put too much information or not.  She can also directly edit the the text  and simultaneously see its effect on the slide.  
8 0
3 years ago
Read 2 more answers
Assignment 1 silly sentences
ololo11 [35]

Answer:

Sally sells sea shells by the sea shore

Explanation:

3 0
3 years ago
Are there any Free programs that let's you use the GreenScrene? But, inside already made videos not while making the video.
Trava [24]
The programs I know that let you use the GreenScreen on already made videos is imovie and SonyVegas Pro. I know how hard it is to find friendly opinions from others so they can help you when trying to find Edit related programs for pictures and videos. I hope this helped.   
5 0
3 years ago
You add a filter by condition, and set the condition to [Weight]&gt;50. How will this affect your data? in tableau
nlexa [21]

It will only show items whose weight is over 50 is the  way it will this affect data. When the computed field is utilized in the filter, only items with a weight greater than 50 are kept.

<h3>How do the person filter by condition in Tableau?</h3>

There are five steps involved in it that are given below-

  • In the Filter Window, go to the 'Condition' tab.
  • Select the 'By field' radio button.
  • From the drop-down list, choose the name of the filtered field.
  • Choose an aggregation type from the drop-down menu, such as Sum, Average, or Median.
  • From the drop-down menu, select the operator.

Thus, It will only show items whose weight is over 50

For more details about person filter by condition in Tableau, click here:

brainly.com/question/25531734

#SPJ1

8 0
2 years ago
What does the presence of the cydia app on an ios device indicate?
Natasha2012 [34]
Had to look for the options and here is my answer. 
Cydia app is an app that is common found on those devices that are jailbroken because this provides third-party custom apps. Therefore, the presence of Cydia app on an iOS device would indicate that the device has been jailbroken. Hope this helps.
6 0
4 years ago
Other questions:
  • The first step in creating photographs with good backgrounds is which of the following? Learning to see the background before ta
    11·2 answers
  • Ideally, how often should you back up the data on your computer? once an hour, once a day, once a month, once a year. Please hur
    5·2 answers
  • With iteration-control systems, each team member ________. is given an account with a set of permissions is given their own priv
    6·1 answer
  • List two advantages and two disadvantages of Satellite Based<br> Augmentation Systems
    8·1 answer
  • Which type of operating system is usually used in personal computers
    13·1 answer
  • Match letters from column B to Column A by looking at the picture above.
    11·1 answer
  • Can anyone help me with these assignments??? Hands On Assignments- Insertion of Symbols, Special Characters, and Images.... and
    9·1 answer
  • High speed printer that produce higher quality printouts but are more expensive is
    15·1 answer
  • A Development team begins work on a new software application and decides to involve the client’s IT experts to ensure that secur
    12·1 answer
  • Which statement best describes a social impact of computing on the world?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!