import java.util.Scanner;
class CompoundInterest {
public static void main(String[] args) {
double principal = 0;
double rate = 0;
double years = 0;
long n = 0;
double amount = 0;
Scanner myScanner = new Scanner(System.in);
System.out.print("Enter the starting principal => ");
principal = myScanner.nextDouble();
System.out.println();
System.out.print("Enter the rate => ");
rate = myScanner.nextDouble();
System.out.println();
System.out.print("Enter the number of years => ");
years = myScanner.nextDouble();
System.out.println();
System.out.print("Enter the number of compundings per year => ");
n = myScanner.nextLong();
System.out.println();
double ratePct = rate / 100;
amount = (float) (principal * Math.pow(1 + ratePct/n, n * years));
System.out.println();
System.out.printf("$%.2f\n",principal);
System.out.printf(" at %.3f%% interest\n", rate);
System.out.printf(" compounded %d times a year\n", n);
System.out.printf(" for %.2f years \n", years);
System.out.printf(" will be worth $%.2f\t", amount);
}
}