Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I am having difficulty with this assignment in Java: 1) Complete theCarclass by creating the purchasePrice (type double) and depreciationRate (type double) attributes, and

Hello, I am having difficulty with this assignment in Java:

1) Complete theCarclass by creating the purchasePrice (type double) and depreciationRate (type double) attributes, and complete the implementation of the getCurrentValue and printInfo methods. The getCurrentValue method is to compute the value using the formula:

 P X ((1 - DR) ^ Y where P is the original purchase price DR is the depreciation rate Y is the number of years since purchase Note: use the getAge method to determine the number of years since purchase. 

The printInfo method is to print the car information.

Ex: If the input is:

2011 Mercedes 28000 .085 

where 2011 is the car's model year, "Mercedes" is the model, 28000 is the purchase price, and .085 is the depreciation rate then printInfo() outputs:

Car's information: Model: Mercedes Year: 2011 Purchase price: $ 28000.00 Current value: $ 12587.74 

Method printInfo must use the getCurrentValue method to obtain the current value.

2) The main method in the Main template currently inputs information to develop an instance of Car, creates an instance, assigns the instance to a variable myCar, and calls the printInfo method on myCar. Add statements to the main to read data of a second car, create the instance assigning it to a variable yourCar and call the printInfo method on your Car. This will result in printing the car information for two cars.

Ex. If the input is:

2011 Mercedes 28000 .085 2020 Fiat 8000 .25 

Then the output will be:

Car's information: Model: Mercedes Year: 2011 Purchase price: $ 28000.00 Current value: $ 12587.74 Car's information: Model: Fiat Year: 2020 Purchase price: $ 8000.00 Current value: $ 8000.00 

3) In the Car class develop a getYearModel method which will return a String formed by concatenating the modelYear with the model separated by a space. For example if the modelYear is 2011 and the model is "Mercedes" then getModelYear will return "2011 Mercedes".

Modify the main method to print a comparative analysis show values now and in the future.

Ex. If the input is:

2011 Mercedes 28000 .085 2020 Fiat 8000 .25 

Then the output which includes the comparative analysis will be:

Car's information: Model: Mercedes Year: 2011 Purchase price: $ 28000.00 Current value: $ 12587.74 Car's information: Model: Fiat Year: 2020 Purchase price: $ 8000.00 Current value: $ 8000.00 Comparative Analysis 2011 Mercedes v. 2020 Fiat Now: $ 12587.74 $ 8000.00 Future: $ 8073.34 $ 1898.44 

When printing the year and model, call the getYearModel method.

To obtain the future values, before print the line with future values, call the method Car.setCurrentYear(2025).(this is after printing the line with current values).As a result, all calls to getCurrentValue will compute a current value relative to the year 2025.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions