Results 1 to 6 of 6

Thread: Debug needed

  1. #1
    Injection is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Exclamation 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:
    *
    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);
    }
    }
    What do I need to do so it'll run? I can't even get the output at this point.
    Last edited by Injection; 02-24-2011 at 09:43 PM.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    It wont run and you don't get errors either?

  3. #3
    NRitH is offline Senior Member
    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    0

    Default

    Here's an idea--in your next reply, copy and paste some of the error you're getting.

  4. #4
    NRitH is offline Senior Member
    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    0

    Default

    And here's hint--use Scanner instead of BufferedReader.

    Scanner (Java 2 Platform SE 5.0)

  5. #5
    Injection is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default

    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.

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    A. This is self evident. What exactly do you not understand about that message?

    B. Read about exception handling.

    C. Go to the Java API and see what parameters the Math.pow method wants and compare to the parameters you are passing.

Similar Threads

  1. Help Debug
    By Desmond in forum New To Java
    Replies: 9
    Last Post: 03-18-2010, 03:33 PM
  2. Help Debug
    By Desmond in forum New To Java
    Replies: 2
    Last Post: 03-18-2010, 12:36 PM
  3. Help with debug
    By SwEeTAcTioN in forum New To Java
    Replies: 9
    Last Post: 11-22-2009, 04:39 AM
  4. Debug challenge: how do you debug a Java program?
    By CJSLMAN in forum New To Java
    Replies: 60
    Last Post: 07-04-2009, 10:28 AM
  5. Eclipse debug tutorial -help needed!!
    By Triji in forum Eclipse
    Replies: 1
    Last Post: 01-27-2009, 01:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •