so, I've tried multiple different things, but I am still getting an answer of infinity when I run this for the last output, what do you think tht the problem is? The first output works fine, but the second and third do not. he exponent is supposed to be ^12*5
. Am i not doing the math.pow
right?
import java.util.Scanner;
public class CompoundInterest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double principal = 0;
double rate = 0;
double time = 0;
double one = 0;
double three = 0;
double five = 0;
double a, b;
System.out.print("Enter the amount of the loan: ");
a = input.nextDouble();
System.out.print("Enter the Rate of interest : ");
b = input.nextDouble();
one = a * Math.pow((1 + b/12),Math.pow(12,1));
three = a * Math.pow((1 + b/12),Math.pow(12,1));
five = a * Math.pow((1 + b/12),Math.pow(12,5));
System.out.println("");
System.out.println("The Compound Interest after 1 year is : "
+ one);
System.out.println("");
System.out.println("The Compound Interest after 3 years is : "
+ three);
System.out.println("");
System.out.println("The Compound Interest after 5 years is : "
+ five);
}
}