hi having a problem with this debugging assignment one error /* Chapter 3 Debugg
ID: 3887212 • Letter: H
Question
hi having a problem with this debugging assignment one error
/*
Chapter 3 Debugging Assignment
Programmer:
Date: February 20, 2016
Program Name: Bert
Purpose: This program will return a name, price of car, downpayment needed, trade-in value,months of loan,
and the interest rate.
*/
import java.io.*;
public class Bert
{
public static void main(String[] args)
{
//Declaring Variables
int price, downpayment, tradeIn, months,loanAmt, interest;
double annualInterest, payment;
double; double custName, inputPrice,inputDownPayment,inputTradeIn,inputMonths, inputAnnualInterest;
BufferedReader dataIn = new BufferedReader(new Inputstreamreader(System.in));
//Get Input from User
System.out.println("What is your name? ");
custName = dataIn.readLine();
System.out.print("What is the price of the car? ");
inputPrice = dataIn.readLine();
System.out.print("What is the downpayment? ");
inputDownPayment = dataIn.readLine();
System.out.print("What is the trade-in value? ");
inputTradeIn = dataIn.readLine();
System.out.print("For how many months is the loan? ");
inputMonths = dataIn.readLine();
System.out.print("What is the decimal interest rate? ");
inputAnnualInterest = dataIn.readLine();
//Conversions
price = Integer.parseInt(inputPrice);
downPayment = Integer.parseInt(inputDownPayment);
tradeIn = Integer.parseInt(inputTradeIn);
months = Integer.parseInt(inputMonths);
annualInterest=Double.parseDouble(inputAnnualInterest);
//Calculations
interest = annualInterest/12;
loanAmt = price + downPayment + tradeIn;
payment=loanAmt/((1/interest)-(1/(interest*Math.pow(1 + "interestmonths" ))));
//Output
System.out.print("The monthly payment for " + custName + " is $");
System.out.println(payment);
}
}
Explanation / Answer
Note: Plz check this and run ...If u want me do further modifications to this program.Just give me message..so that I will modify...Thank You.
___________________
Bert.java
import java.io.*;
public class Bert {
public static void main(String[] args) throws IOException {
// Declaring Variables
int price, downpayment, tradeIn, months, loanAmt, downPayment;
double interest;
double annualInterest, payment;
String custName;
String inputPrice, inputDownPayment, inputTradeIn, inputAnnualInterest, inputMonths;
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
// Get Input from User
System.out.println("What is your name? ");
custName = dataIn.readLine();
System.out.print("What is the price of the car? ");
inputPrice = dataIn.readLine();
System.out.print("What is the downpayment? ");
inputDownPayment = dataIn.readLine();
System.out.print("What is the trade-in value? ");
inputTradeIn = dataIn.readLine();
System.out.print("For how many months is the loan? ");
inputMonths = dataIn.readLine();
System.out.print("What is the decimal interest rate? ");
inputAnnualInterest = dataIn.readLine();
// Conversions
price = Integer.parseInt(inputPrice);
downPayment = Integer.parseInt(inputDownPayment);
tradeIn = Integer.parseInt(inputTradeIn);
months = Integer.parseInt(inputMonths);
annualInterest = Double.parseDouble(inputAnnualInterest);
// Calculations
interest = annualInterest / 12;
interest /= 100.0;
loanAmt = price + downPayment + tradeIn;
//payment = loanAmt/ ((1 / interest) - (1 / (interest * Math.pow(1 + interest,months))));
payment=(loanAmt*interest) / (1-Math.pow(1+interest, -months));
// Output
System.out.print("The monthly payment for " + custName + " is $");
System.out.println(payment);
}
}
______________________
Output:
What is your name?
Williams
What is the price of the car? 300000
What is the downpayment? 10000
What is the trade-in value? 2000
For how many months is the loan? 36
What is the decimal interest rate? 17
The monthly payment for Williams is $11123.650988344341
______________Thank You
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.