import java.lang.reflect.Array;
import java.sql.Struct;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class CompoundsInterestDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
double interest=0.064,futureValue,presentValue=1000000;
int year=5;
futureValue=payforonce(year,interest,presentValue);
System.out.println(futureValue);
int month = year*12 ;
long principal=1000000;
double monthlyInterestRate = interest/12;
double MatchingInterestPayment;
MatchingInterestPayment = MatchingInterestPayment(principal,monthlyInterestRate,month);
System.out.println(MatchingInterestPayment);
Scanner console = new Scanner(System.in);
int d = console.nextInt();
year = d;
futureValue=payforonce(year,interest,presentValue);
System.out.println(futureValue);
month = year*12 ;
monthlyInterestRate = interest/12;
MatchingInterestPayment = MatchingInterestPayment(principal,monthlyInterestRate,month);
System.out.println(MatchingInterestPayment);
}
public static double payforonce (int year, double interest,double presentValue){
double futureValue ;
futureValue = presentValue*Math.pow(interest+1, year);
return futureValue;
}
public static double MatchingInterestPayment(long principal,double monthlyInterestRate,int month){
double monthlyRepaymentAmount;
monthlyRepaymentAmount =principal*monthlyInterestRate*Math.pow(monthlyInterestRate+1,month)/(Math.pow(monthlyInterestRate+1,month)-1);
return monthlyRepaymentAmount;
}
public static ArrayList MatchingMonthlyRepaymentofPrincipal(long principal,int month,long paidprincipal,double monthlyInterestRate,int PayMonths){
double MonthlyPayPrincipal=(double)principal/12;
double MonthLyInterest=(principal-MonthlyPayPrincipal*PayMonths)*monthlyInterestRate;
double TotalInterest=(month+1)*principal*monthlyInterestRate/2;
double TotalPay=TotalInterest+principal;
ArrayList list=new ArrayList();
list.add(MonthlyPayPrincipal);
list.add(TotalInterest);
list.add(TotalPay);
return list;
}
}
import java.sql.Struct;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class CompoundsInterestDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
double interest=0.064,futureValue,presentValue=1000000;
int year=5;
futureValue=payforonce(year,interest,presentValue);
System.out.println(futureValue);
int month = year*12 ;
long principal=1000000;
double monthlyInterestRate = interest/12;
double MatchingInterestPayment;
MatchingInterestPayment = MatchingInterestPayment(principal,monthlyInterestRate,month);
System.out.println(MatchingInterestPayment);
Scanner console = new Scanner(System.in);
int d = console.nextInt();
year = d;
futureValue=payforonce(year,interest,presentValue);
System.out.println(futureValue);
month = year*12 ;
monthlyInterestRate = interest/12;
MatchingInterestPayment = MatchingInterestPayment(principal,monthlyInterestRate,month);
System.out.println(MatchingInterestPayment);
}
public static double payforonce (int year, double interest,double presentValue){
double futureValue ;
futureValue = presentValue*Math.pow(interest+1, year);
return futureValue;
}
public static double MatchingInterestPayment(long principal,double monthlyInterestRate,int month){
double monthlyRepaymentAmount;
monthlyRepaymentAmount =principal*monthlyInterestRate*Math.pow(monthlyInterestRate+1,month)/(Math.pow(monthlyInterestRate+1,month)-1);
return monthlyRepaymentAmount;
}
public static ArrayList MatchingMonthlyRepaymentofPrincipal(long principal,int month,long paidprincipal,double monthlyInterestRate,int PayMonths){
double MonthlyPayPrincipal=(double)principal/12;
double MonthLyInterest=(principal-MonthlyPayPrincipal*PayMonths)*monthlyInterestRate;
double TotalInterest=(month+1)*principal*monthlyInterestRate/2;
double TotalPay=TotalInterest+principal;
ArrayList list=new ArrayList();
list.add(MonthlyPayPrincipal);
list.add(TotalInterest);
list.add(TotalPay);
return list;
}
}