I'm getting this progm to run but vis producing no out put.
I'm getting this progm to run but vis producing no out put.
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();
}
}
the calculations are performed in this prigram.
private int currentValue;
public void setModelYear(int userYear){
modelYear = userYear;
}
public int getModelYear() {
return modelYear;
}
// Define setPurchasePrice() method
public double setPurchasePrice(int userPrice){
return purchasePrice;
}
// Define getPurchasePrice() method
public double getPurchasePrice(int userPrice){
return purchasePrice;
}
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));
}
// Define printInfo() method to output modelYear, purchasePrice, and currentValue
public void printInfo(){
System.out.println("Car's information: ");
System.out.println(" Model year:" + modelYear);
System.out.println(" Purchase price: $" + purchasePrice);
System.out.println(" Current value: $" + currentValue);
}
}
After fixing some errors, I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT---------------
Step by step
Solved in 4 steps with 3 images