import java.io.*;
public class Amortization   { 
    public static void main (String[] args)throws IOException    {
        BufferedReader dataIn=new BufferedReader (new InputStreamReader (System.in));
        double loanamount=0.0, interestrate=0.0, numberofyears=0.0,amortization=0.0, a=(1+interestrate),b=numberofyears ; 
        String TextInput;
        System.out.print ("Input the loan amount: ") ; 
        TextInput=dataIn.readLine () ; 
        loanamount=Integer.parseInt (TextInput) ;
        TextInput=dataIn.readLine () ;
        System.out.print ("Input the interest rate: ") ; 
        TextInput=dataIn.readLine () ; 
        interestrate=Integer.parseInt (TextInput) ;
        TextInput=dataIn.readLine ()  ;
        System.out.print ("Input the number of years: ") ; 
        TextInput=dataIn.readLine () ; 
        numberofyears=Integer.parseInt (TextInput) ;
        TextInput=dataIn.readLine () ;
        amortization=loanamount*(interestrate*(1+interestrate)^numberofyears)/(1+interestrate)^numberofyears-1;
        System.out.println ("Monthly Amortization is: "+amortization) ; 
    }
}

I don't know how to put 'number of years' in exponent form. The user has to input loan amount, interest rate, and number of years.
I'm really new to this, so please bear with me. thanks guys!

import java.io.*;
public class Amortization {
public static void main (String[] args)throws IOException {
BufferedReader dataIn=new BufferedReader (new InputStreamReader (System.in));
double loanamount=0.0, interestrate=0.0, numberofyears=0.0,amortization=0.0, a=(1+interestrate),b=numberofyears ;
String TextInput;
System.out.print ("Input the loan amount: ") ;
TextInput=dataIn.readLine () ;
loanamount=Integer.parseInt (TextInput) ;
TextInput=dataIn.readLine () ;
System.out.print ("Input the interest rate: ") ;
TextInput=dataIn.readLine () ;
interestrate=Integer.parseInt (TextInput) ;
TextInput=dataIn.readLine () ;
System.out.print ("Input the number of years: ") ;
TextInput=dataIn.readLine () ;
numberofyears=Integer.parseInt (TextInput) ;
TextInput=dataIn.readLine () ;
amortization=loanamount*(interestrate*(1+interestrate)^numberofyears)/(1+interestrate)^numberofyears-1;
System.out.println ("Monthly Amortization is: "+amortization) ;
}
}

I don't know how to put 'number of years' in exponent form. The user has to input loan amount, interest rate, and number of years.
I'm really new to this, so please bear with me. thanks guys!

You can use java.lang.Math.pow((1+interestrate),numberofyears). This method returns type double.

preferrably, you can have a variable to store (1+interestrate) and another for (numberofyears-1) as below:

//Some of your code
double onePlusInterestRate =0.0, numberofyearsMinusOne=0.0;
onePlusInterestRate = 1+interestrate;
numberofyearsMinusOne = numberofyears-1;
//Some more of your code
amortization=loanamount*(interestrate*java.lang.Math.pow(onePlusInterestRate,numberofyears)/java.lang.Math.pow(onePlusInterestRate , numberofyearsMinusOne)

Hope this helps! (If it does just mark it as solved after my comments, Thanks)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.