java - loan calculator that implements multiple methods -
i have been working on program java loan payment calculator comp sci class. programs requriements are:
- ask user loan amount, annual interest rate, , number of months
- call method calculate , return monthly interest rate
- call method calculate , return monthly payments
- call method print loan statement showing amount borrowed, annual interest rate, number of months , monthly payment.
this first time working multiple methods. have developed code far shown below. netbeans editor not giving me errors, however, not print statements last method. questions are:
- are methods set correctly , passing parameters correctly
- why won't statements print @ end
- am capturing other methods correctly? need enter variables in main method , call them in final method.
- is of code redundant?
i not sure how proceed here.
public class carloan { /** * @param args command line arguments */ public static void main(string[] args) { // declare variables main method double loanamount;//double value loan amount double annualinterestrate;//double value interest rate int numberofmonths;//int value number of months double monthlypayment; scanner keyboard = new scanner(system.in); system.out.println("please enter amount of loan."); loanamount = keyboard.nextdouble(); system.out.println("please enter annual interest rate decimal. ex. 7.5% = .075"); annualinterestrate = keyboard.nextdouble(); system.out.println("please enter number of months have pay loan."); numberofmonths = keyboard.nextint(); } ************************************************* public static double calcmonthlyinterestrate(double annualinterestrate){ double monthlyinterestrate; monthlyinterestrate = (annualinterestrate/12); return monthlyinterestrate; }//end method calcmonthlyinterestrate ************************************************************************************** public static double calcmonthlypayment(double monthlyinterestrate, double loanamount, int numberofmonths ){ double monthlypayment; double calcmonthlypayment; calcmonthlypayment = (monthlyinterestrate*loanamount)/(1-(1+monthlyinterestrate)-numberofmonths); return monthlypayment = calcmonthlypayment; }//end method calcmonthlypayment **************************************************************************************** public static void loanstatment (double loanamount, double annualinterestrate, intnumberofmonths, double monthlypayment){ system.out.println("your loan amount " +loanamount); system.out.println(annualinterestrate); system.out.println(numberofmonths); system.out.println(monthlypayment); } }//end main method }//end main method
have @ main method , see doing declaring variables , receiving input. other methods perform calculations , loanstatment (sic) method prints results never called.
i recommend read on basics waste less of time simple errors one.
Comments
Post a Comment