I Want Explanation Of This Program 3 4pp How To Create Methods To Calculate And
I want explanation of this program,
/**
* 3.4PP how to create methods to calculate and return values (functions)
*Calculate how much interest you will get on an investment.
* @author Supriya Kale
*/
public class InvestmentCalc {
public static double compoundInterest(int principal, int periods, double rate) {
return principal * Math.pow(1 + rate, periods)- principal;
}
public static void main (String[] args){
Scanner sc = new Scanner (System.in);
int principal = 0;
int periods = 0;
double rate = 0;
System.out.println(“Investment Calculator”);
System.out.println(“Bank A: $” + compoundInterest(1000,3,0.035));
System.out.println(“Bank B: $” + compoundInterest(1000,3,0.045));
System.out.println(“Input principle ($):”);
principal = sc.nextInt();
System.out.println(“Input interest rate (percent):”);
rate = sc.nextDouble();
System.out.println(“CALCULATING…”);
rate = rate / 100;
System.out.println(“5 year investment $: ” +
compoundInterest(principal,5,rate));
}
}
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
