You will be creating two classes: Automobile and TestAutomobile.

Automobile class includes a constructor, the If statements as needed to test the values, use of get and set methods, display method, Accelerate method to increase the speed by 5, overloaded accelerate method to allow the designated speed change, brake method to decrease the speed by 5 overloaded brake method to allow designated speed change.

TestAutomobile initializes 2-3 automobile objects and demonstrates that all the methods in the Automobile class are working correctly.

Create an Automobile class for a dealership. Include fields for an ID number, make, model, color, year, vin number, miles per gallon, and speed. Include get and set methods for each field. Do not allow the ID to be negative or more than 9999; if it is, set the ID to 0. Do not allow the year to be earlier than 2000 or later than 2017; if it is, set the year to 0. Do not allow the miles per gallon to be less than 10 or more than 60; if it is, set the miles per gallon to 0. Car speed should be initialized as 0. Include a constructor that accepts arguments for each field value and uses the set methods to assign the values. Also write two methods, Accelerate () and Brake (). Whenever Accelerate () is called, increase the speed by 5, and whenever Brake () is called, decrease the speed by 5. To allow users to specify the speed to increase (or decrease), create two overloading methods for Accelerate () and Brake () that accept a single parameter specifying the increasing (or decreasing) speed. Write an application that declares several Automobile objects and demonstrates that all the methods work correctly. Save the files as Automobile.java and TestAutomobiles.java.

Discussion

  • What are the issues that may arise while using the IF statement?
  • In what circumstances would IF ELSE be a preferred statement over SWITCH and vice versa? Please use real-world examples to support your arguments.
  • Use specific, real-world examples to describe the uses of the logical AND operator (&&), the logical OR operator (||), the logical NOT operator (!) and the combination of those operators in making decisions.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.