Question
Please help me with this code Create a class named Car that contains the following data fields: make of type String model of type String
Please help me with this code
- Create a class named Car that contains the following data fields:
- make of type String
- model of type String
- year of type int
- miles of type int
- msrp of type double
- Include get and set methods for these fields. The methods should be prefixed with 'get' or 'set' respectively, followed by the field name using camel case. For example, setMake.
- Include 2 constructors.
- The first constructor should have no arguments and sets the data fields to default values.
- The second should have 5 arguments that set the values of all the data fields.
- Write a class named TestCar that contains a main method, which instantiates two car objects.
- The first car object should be instantiated by calling the overloaded constructor from step 3b.
- The second car object should be instantiated by calling the default constructor. The values of the second cars data fields should be set using the set methods. (Refer to example TestSandwich programming exercise 3-11)
- In TestCar, create a static method called calculatePrice that takes in 5 argumets: (1) make, (2) model, (3) year, (4) miles, and (5) msrp, then displays the price for each car. Your output should look like:
A 2016 Chevrolet Camaro with 24500.0$ msrp driven for 50 miles sells for 19600.0$.
A 2012 Toyota RAV4 with 22500.0$ msrp driven for 130 miles sells for 10800.0$.
The current price of the car is based off the percentage of the remaining miles. If a car can run up to 250 miles, the current price of the car, p = msrp [(miles/250) * msrp].
- In the main method, call calculatePrice twice. Once using all get methods from the first car object, and the second using all get methods from the second car object. The get methods calls should be inserted as arguments for calculatePrice. (Refer to example TestSandwich programming exercise 3-11)
- Comment your codes thoroughly.
- The main class header should have the following document comment, and filled:
/**
* Homework#
* Author:
* Date:
* Description:
*/
- Each method and class header should have comments that follow or be as close as possible to the Java documentation.
Each variable declaration, method call, and mathematical assignment should be preceded by a single line comment explaining what the line of code is meant to do
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started