Question: hey whats up, I'm working on my car java program and needed some help finishing it. Feel free to edit it. The car,java and cartester

hey whats up, I'm working on my car java program and needed some help finishing it. Feel free to edit it. The car,java and cartester code shouldn't be changed just the code in the carlot class according to the instructions

hey whats up, I'm working on my car java program and needed

CarLotTester Class:

import java.util.ArrayList; import java.text.DecimalFormat; public class CarLotTester { public static void main(String[] args) { ArrayList carLot = new ArrayList(); carLot.add(new Car("Cadillac", "Silver", "Escalade", 2010, 87258, 20000)); carLot.add(new Car("Chevrolet", "Black", "Equinox", 2017, 90626, 13470)); carLot.add(new Car("Chevrolet", "White", "Malibu", 2018, 51470, 13434)); carLot.add(new Car("Genesis", "Blue", "G80", 2017, 33273, 26000)); carLot.add(new Car("Infiniti", "Black", "EX37", 2013, 84895, 13968)); carLot.add(new Car("Jeep", " Tango", "Wrangler Sport", 2011, 82946, 18991)); carLot.add(new Car("Lexus", "Silver", "IS 300", 2016, 15090, 25000)); carLot.add(new Car("Nissan", "White", "Altima", 2017, 90522, 11457)); carLot.add(new Car("Rolls-Royce", "Black", "Silver Spirit", 1986, 87111, 17777)); CarLot myCarLot = new CarLot(carLot); DecimalFormat numberFormat = new DecimalFormat("#.00"); System.out.println("The value of all cars are: $" +numberFormat.format(myCarLot.getValuation())); System.out.println("The expected value of all cars are: $160097.00"); System.out.println(""); System.out.println("The value of all Black color cars are: $" + numberFormat.format(myCarLot.getValuationByColor("Black"))); System.out.println("The expected value Black color cars are: $45215.00"); } }

Carlot Class (It prints out a weird value)

import java.util.ArrayList; /** * CarLot class has a constructor of cars as an array list. * This class also consists of two methods getValuation and gatValuationByColor which * can get either the total value of cars in the car lot or get a total value of a color car * within the car lot * * public class CarLot { private ArrayList car; private double total =0; /** * Constructs an Arraylist of cars * @param cars : car */ public CarLot(ArrayList cars) { car=cars; } /** * GetValuation() method will calculate all of values in the car lot * @return the total value of all cars */ public double getValuation() { for(int i=0; i

Car Class

public class Car { private String carMake, carColor, carModel; private int carYear; private double carMiles, carValue; public Car(String make, String color, String model, int year, double miles, double value) { carMake = make; carColor = color; carModel = model; carYear = year; carMiles = miles; carValue = value; } public String getMake() { return carMake; } public String getColor() { return carColor; } public String getModel() { return carModel; } public int getYear() { return carYear; } public double getMiles() { return carMiles; } public double getValue() { return carValue; } }

Learning Objectives A car dealership maintains an inventory of cars with an arrayList named carlot. The partial definition is shown below: ArrayList carlot = new ArrayList(); The dealership would like to be able to determine the total value of cars in their inventory and the total value of cars in their inventory by color. You are to create a new class Carlot that will have the following methods to do just that. Constructor: that accepts an arrayList of Cars getValuation: That does not have any parameters but will calculate and return the total valuation of the car lot. getValuation By Color: That has one parameter that represents that color of car to get valuation or. This method will calculate and return the total valuation of the car lot by color. You are given the tester and the Car class; your logic should work with this logic and therefore should not change this logic

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!