Results 1 to 6 of 6
Thread: Debug needed
- 02-24-2011, 09:41 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Debug needed
Hi,
I take a programming class and my group needs help debugging this code. We can't figure it out and have tried everything but still always get random errors. Using Netbeans IDE 6.9.1
Here's the original code:
What do I need to do so it'll run? I can't even get the output at this point.*
Chapter 3 Debugging Assignment
Programmer:
Date:
Program Name: Bert,java
Purpose:
*/
import java.io.*;
public class Bert
{
public static void main(String[] args)
{
//Declaring Variables
int price, downpayment, tradeIn, months,loanAmt, interest;
double annualInterest, payment;
String custName, inputPrice,inputDownPayment,inputTradeIn,inputMont hs, 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+interest months));
//Output
System.out.print("The monthly payment for " + custName + " is $");
System.out.println(payment);
}
}Last edited by Injection; 02-24-2011 at 09:43 PM.
- 02-24-2011, 10:48 PM #2
It wont run and you don't get errors either?
- 02-24-2011, 11:34 PM #3
Senior Member
- Join Date
- Feb 2011
- Posts
- 118
- Rep Power
- 0
Here's an idea--in your next reply, copy and paste some of the error you're getting.
- 02-24-2011, 11:36 PM #4
Senior Member
- Join Date
- Feb 2011
- Posts
- 118
- Rep Power
- 0
And here's hint--use Scanner instead of BufferedReader.
Scanner (Java 2 Platform SE 5.0)
- 02-25-2011, 12:13 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Thanks guys -
Errors I'm getting (from top to bottom):
A. class Bert is public, should be declared in a file named Bert.java
B. unreported exception java.io.IOException; must be caught or declared to be thrown
C. method pow in method java.lang.Math cannot be applied to given types required; double double
And for times sake, I don't think I should implement Scanner for now. I'm pretty sure the bolded part is the root of this whole problem I'm having.Last edited by Injection; 02-25-2011 at 12:16 AM.
- 02-25-2011, 12:29 AM #6
Similar Threads
-
Help Debug
By Desmond in forum New To JavaReplies: 9Last Post: 03-18-2010, 03:33 PM -
Help Debug
By Desmond in forum New To JavaReplies: 2Last Post: 03-18-2010, 12:36 PM -
Help with debug
By SwEeTAcTioN in forum New To JavaReplies: 9Last Post: 11-22-2009, 04:39 AM -
Debug challenge: how do you debug a Java program?
By CJSLMAN in forum New To JavaReplies: 60Last Post: 07-04-2009, 10:28 AM -
Eclipse debug tutorial -help needed!!
By Triji in forum EclipseReplies: 1Last Post: 01-27-2009, 01:38 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks