Friday 15 August 2014

(Java Beginner) - Having trouble with a program -



(Java Beginner) - Having trouble with a program -

ok working on programme involves loans , gives info user loans user inputs.

the purpose of programme writing user asked input loan amount , number of years have pay off. 1 time user has given information, programme take loan amount , number of years , tell user annual involvement rate, monthly payment , total amount. also, if user enters loan amount of -1, programme supposed terminate.

below code far:

package loans; import java.util.scanner; public class loans { public static void main(string[] args) { scanner input = new scanner (system.in); double monthlyinterestrate; double annualinterestrate; double monthlypayment; double total; double numberofyears; double loanamount; system.out.println("this programme compute monthly payments , total payments loan amount on involvement rates starting @ 5%, incrementing 1/8th percent 8%."); //formula calculate monthly involvement rate: monthlyinterestrate = (annualinterestrate/1200); //formula calculate monthly payment: monthlypayment = (loanamount*monthlyinterestrate); //formula calculate annual involvement rate: annualinterestrate = (1-(math.pow(1/(1 + monthlyinterestrate), numberofyears * 12))); //formula calculate total payment: total = (monthlypayment*numberofyears*12); while(true) { system.out.println("please come in in loan amount."); double loanamount = input.nextdouble(); system.out.println("please come in in number of years."); double numberofyears = input.nextdouble(); system.out.println("interest rate: " + annualinterestrate); system.out.println("monthly payment: " + monthlypayment); system.out.println("total payment: " + total); } } }

this not compile , i'm not sure why. (again, i'm beginner)

the errors receiving on line reads "double loanamount = input.nextdouble();" , line reads "double numberofyears = input.nextdouble();".

the error first line says, "duplicate local variable loanamount".

the error sec line says, "multiple markers @ line - line breakpoint:loans [line: 39] - main(string[]) - duplicate local variable numberofyears"

any feedback appreciated.

the error pretty much self explanatory. have defined both "loanamount" , "numberofyears" 2 times in main. either rename them or declare them once.

if beginner in coding recommend utilize ide eclipse or netbeans. point out compilation errors along suggestions on how prepare them.

java

No comments:

Post a Comment