Results 1 to 3 of 3

Thread: Loop driving me loopy!!!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    5

    Loop driving me loopy!!!!!

    Any advise on what is wrong with my loop please?

    public static void main (String[]arg){

    double loan;
    double wages;
    final int THRESHOLD= 10000;
    double netInc;
    double newBal=0;
    double totalLoan;
    double deduction;


    System.out.println("Enter total amount of student loan taken");
    loan=UserInput.readDouble();

    System.out.println("Enter anticipated income");
    wages=UserInput.readDouble();

    newBal=loan*0.03;

    netInc=wages-THRESHOLD;
    deduction=netInc*0.09;

    totalLoan=loan+newBal;

    newBal=totalLoan-deduction;




    System.out.println("Loan taken out: "+loan+" anticipated income "+wages);
    System.out.println("Total plus interest: "+totalLoan);
    System.out.println("Amount Re-paid: "+ deduction);
    System.out.println("New balance: "+newBal);


    }
    public static calculate(double amount)
    {


    while(newBal >0.0){


    newBal=loan*0.03;

    netInc=wages-THRESHOLD;
    deduction=netInc*0.09;

    totalLoan=loan+newBal;

    newBal=totalLoan-deduction;

    System.out.println("Loan taken out: "+loan+" anticipated income "+wages);
    System.out.println("Total plus interest: "+totalLoan);
    System.out.println("Amount Re-paid: "+ deduction);
    System.out.println("New balance: "+newBal);
    }

    else {

    System.out.println("end ");

    }

    }




    }//end main

    }//end class

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Loop driving me loopy!!!!!

    Yeah. The white space, the indentation and the code tag
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Loop driving me loopy!!!!!

    If your problem is that the loop is not running, it's because calculate() is not called anywhere within main.

    Or did you leave out some code?

    and oh,
    Code:
    public static calculate()
    is not a proper function signature

    you need to add a return type

Posting Permissions

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



Click Here to Expand Forum to Full Width