Results 1 to 3 of 3
  1. #1
    soc86 is offline Member
    Join Date
    Oct 2008
    Posts
    39
    Rep Power
    0

    Default MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")

    My code is working fine apart from the last two lines:

    MoneyOut.println("It took you ",year," years to repay the loan");
    MoneyOut.println("The original loan was ",firstBal," but you had to pay back ",totalRepay);

    I believe the error is where i am entering variables inbetween the text ie, ",year," any advise?


    public static void main (String[]arg){
    //declare variables
    double loan;
    double wages;
    final int THRESHOLD= 10000;
    double netInc=0;
    double newBal=0;
    double totalLoan;
    double deduction;
    double firstBal;
    int year=1;
    double totalRepay=0;

    //print qoute
    System.out.println("Enter total amount of student loan taken");
    loan=UserInput.readDouble();
    //print qoute
    System.out.println("Enter anticipated income");
    wages=UserInput.readDouble();

    firstBal = newBal-0;

    while (newBal >= 0) {

    newBal=loan*0.03;

    netInc=wages-THRESHOLD;
    if (netInc>0)
    deduction=netInc*0.09;
    else
    deduction =0;

    totalLoan=loan+newBal;

    newBal=totalLoan-deduction;

    totalRepay= totalRepay+deduction;

    MoneyOut.println("Year: "+year+" Old loan: ",loan);
    MoneyOut.println("Loan plus 3% interest: " ,totalLoan);
    MoneyOut.println("wages: ",wages);
    MoneyOut.println("Wages minus threshold: " ,netInc);
    MoneyOut.println("Amount Re-paid: ",deduction);
    MoneyOut.println("New loan amount: ",newBal);

    loan=newBal+0;
    wages=wages +(wages*0.05);
    year=year+1;
    }

    year=year-1;

    MoneyOut.println("It took you ",year," years to repay the loan");
    MoneyOut.println("The original loan was ",firstBal," but you had to pay back ",totalRepay);






    }//end main

    }//end class

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default

    You seriously have to learn to look things up... You even have correctly used println in your program in some cases:
    Java Code:
    MoneyOut.println("It took you "[B][COLOR="Blue"]+[/COLOR][/B]year[B][COLOR="Blue"]+[/COLOR][/B]" years to repay the loan"); 
    MoneyOut.println("The original loan was "[B][COLOR="Blue"]+[/COLOR][/B]firstBal[B][COLOR="Blue"]+[/COLOR][/B]" but you had to pay back "[B][COLOR="Blue"]+[/COLOR][/B]totalRepay);
    There are other printlns that you have to correct also.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 04:03 AM
  2. Replies: 1
    Last Post: 10-20-2008, 08:35 AM
  3. <core:forEach var="" begin="+<%=j%>+">???
    By freddieMaize in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2008, 02:20 AM
  4. Replies: 11
    Last Post: 08-19-2008, 12:29 PM
  5. "Jumble" or "Scramble" Program
    By Shadow22202 in forum Java Applets
    Replies: 8
    Last Post: 04-30-2008, 04:42 AM

Posting Permissions

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