I have 2 java files. Car.java and CarValue.Java. Car.java looks like " public class Car { private int modelYear; // TODO: Declare purchasePrice field (int) private int currentValue; public void setModelYear(int userYear){ modelYear = userYear; } public int getModelYear() { return modelYear; } // TODO: Define setPurchasePrice() method // TODO: Define getPurchasePrice() method public void calcCurrentValue(int currentYear) { double depreciationRate = 0.15; int carAge = currentYear - modelYear; // Car depreciation formula currentValue = (int) Math.round(purchasePrice * Math.pow((1 - depreciationRate), carAge)); } // TODO: Define printInfo() method to output modelYear, purchasePrice, and currentValue }". While CarValue.java looks like " import java.util.Scanner; import java.lang.Math; public class CarValue { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Car myCar = new Car(); int userYear = scnr.nextInt(); int userPrice = scnr.nextInt(); int userCurrentYear = scnr.nextInt(); myCar.setModelYear(userYear); myCar.setPurchasePrice(userPrice); myCar.calcCurrentValue(userCurrentYear); myCar.printInfo(); } }". I need to insert the right code into specifically Car.java so when I input "2011 18000 2018" the output is "Car's information: Model year: 2011 Purchase price: 18000 Current value: 5770". My current code is: public class Car { private int modelYear; private int purchasePrice; private int currentValue; public int getModelYear() { return modelYear; } public void setModelYear(int userYear) { this.modelYear = userYear; } public int getPurchasePrice() { return purchasePrice; } public void setPurchasePrice(int userPrice) { this.purchasePrice = userPrice; } public int getCurrentValue() { return currentValue; } public void calcCurrenValue(int userCurrentYear){ double depreciationRate = 0.15; int carAge = userCurrentYear-modelYear; currentValue = (int)Math.round(purchasePrice * Math.pow((1-depreciationRate),carAge)); } public void printInfo(){ System.out.println("Car's Information:"); System.out.println(" Model year: "+getModelYear()); System.out.println(" Purchase price: "+getPurchasePrice()); System.out.println(" Current valud: "+getCurrentValue()); } }. But when I run it it keeps saying "CarValue.java:16: error: cannot find symbol myCar.calcCurrentValue(userCurrentYear); ^ symbol: method calcCurrentValue(int) location: variable myCar of type Car 1 error"

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I have 2 java files. Car.java and CarValue.Java. Car.java looks like "

public class Car {
private int modelYear;
// TODO: Declare purchasePrice field (int)

private int currentValue;

public void setModelYear(int userYear){
modelYear = userYear;
}

public int getModelYear() {
return modelYear;
}

// TODO: Define setPurchasePrice() method

// TODO: Define getPurchasePrice() method


public void calcCurrentValue(int currentYear) {
double depreciationRate = 0.15;
int carAge = currentYear - modelYear;

// Car depreciation formula
currentValue = (int)
Math.round(purchasePrice * Math.pow((1 - depreciationRate), carAge));
}

// TODO: Define printInfo() method to output modelYear, purchasePrice, and currentValue

}". While CarValue.java looks like "

import java.util.Scanner;
import java.lang.Math;

public class CarValue {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);

Car myCar = new Car();

int userYear = scnr.nextInt();
int userPrice = scnr.nextInt();
int userCurrentYear = scnr.nextInt();

myCar.setModelYear(userYear);
myCar.setPurchasePrice(userPrice);
myCar.calcCurrentValue(userCurrentYear);

myCar.printInfo();
}
}".

I need to insert the right code into specifically Car.java so when I input "2011 18000 2018" the output is "Car's information: Model year: 2011 Purchase price: 18000 Current value: 5770".

My current code is: public class Car { private int modelYear; private int purchasePrice; private int currentValue; public int getModelYear() { return modelYear; } public void setModelYear(int userYear) { this.modelYear = userYear; } public int getPurchasePrice() { return purchasePrice; } public void setPurchasePrice(int userPrice) { this.purchasePrice = userPrice; } public int getCurrentValue() { return currentValue; } public void calcCurrenValue(int userCurrentYear){ double depreciationRate = 0.15; int carAge = userCurrentYear-modelYear; currentValue = (int)Math.round(purchasePrice * Math.pow((1-depreciationRate),carAge)); } public void printInfo(){ System.out.println("Car's Information:"); System.out.println(" Model year: "+getModelYear()); System.out.println(" Purchase price: "+getPurchasePrice()); System.out.println(" Current valud: "+getCurrentValue()); } }.

But when I run it it keeps saying "CarValue.java:16: error: cannot find symbol myCar.calcCurrentValue(userCurrentYear); ^ symbol: method calcCurrentValue(int) location: variable myCar of type Car 1 error"

```java
public class Car {
    private int modelYear;
    private int purchasePrice;
    private int currentValue;

    public int getModelYear() {
        return modelYear;
    }

    public void setModelYear(int userYear) {
        this.modelYear = userYear;
    }

    public int getPurchasePrice() {
        return purchasePrice;
    }

    public void setPurchasePrice(int userPrice) {
        this.purchasePrice = userPrice;
    }

    public int getCurrentValue() {
        return currentValue;
    }

    public void calcCurrentValue(int userCurrentYear) {
        double depreciationRate = 0.15;
        int carAge = userCurrentYear - modelYear;
        currentValue = (int) Math.round(purchasePrice * Math.pow(1 - depreciationRate, carAge));
    }

    public void printInfo() {
        System.out.println("Car's Information:");
        System.out.println("   Model year: " + getModelYear());
        System.out.println("   Purchase price: " + getPurchasePrice());
        System.out.println("   Current value: " + getCurrentValue());
    }
}
```

This Java class, `Car`, represents a car with fields for model year, purchase price, and current value. It includes getter and setter methods for the model year and purchase price, and a method to calculate the current value based on depreciation. The current value is calculated using a simple exponential depreciation formula with a rate of 15%. There is also a method to print out the car's information, displaying its model year, purchase price, and current value.
Transcribed Image Text:```java public class Car { private int modelYear; private int purchasePrice; private int currentValue; public int getModelYear() { return modelYear; } public void setModelYear(int userYear) { this.modelYear = userYear; } public int getPurchasePrice() { return purchasePrice; } public void setPurchasePrice(int userPrice) { this.purchasePrice = userPrice; } public int getCurrentValue() { return currentValue; } public void calcCurrentValue(int userCurrentYear) { double depreciationRate = 0.15; int carAge = userCurrentYear - modelYear; currentValue = (int) Math.round(purchasePrice * Math.pow(1 - depreciationRate, carAge)); } public void printInfo() { System.out.println("Car's Information:"); System.out.println(" Model year: " + getModelYear()); System.out.println(" Purchase price: " + getPurchasePrice()); System.out.println(" Current value: " + getCurrentValue()); } } ``` This Java class, `Car`, represents a car with fields for model year, purchase price, and current value. It includes getter and setter methods for the model year and purchase price, and a method to calculate the current value based on depreciation. The current value is calculated using a simple exponential depreciation formula with a rate of 15%. There is also a method to print out the car's information, displaying its model year, purchase price, and current value.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY