Results 1 to 3 of 3
- 01-23-2009, 11:23 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 39
- Rep Power
- 0
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
- 01-23-2009, 12:31 PM #2
You seriously have to learn to look things up... You even have correctly used println in your program in some cases:
There are other printlns that you have to correct also.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);
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 01-24-2009, 06:56 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
At least please read carefully the error message you get soc86.
It's all about string concatenation in Java. Actually it's common in many languages.
Similar Threads
-
Java, Military Format using "/" and "%" Operator!!
By sk8rsam77 in forum New To JavaReplies: 11Last Post: 02-26-2010, 03:03 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM -
<core:forEach var="" begin="+<%=j%>+">???
By freddieMaize in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 09-27-2008, 01:20 AM -
[SOLVED] HELP! Is this BUG? System.out.println() always shows "@9304b1"
By dark_cybernetics in forum New To JavaReplies: 11Last Post: 08-19-2008, 11:29 AM -
"Jumble" or "Scramble" Program
By Shadow22202 in forum Java AppletsReplies: 8Last Post: 04-30-2008, 03:42 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks