import java.io.*;
import java.util.Scanner;
public class Invest{
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
double principal = 0;
double rate = 0;
int years = 0;
double total = 0;
int yearCount = 1;
double gain = 0;
System.out.println ("Enter your initial investment amount: ");
principal = reader.nextDouble();
System.out.println ("Enter the number of years: ");
years = reader.nextInt();
System.out.println ("Enter the interst rate: ");
rate = reader.nextDouble();
years = reader.nextInt();
System.out.printf("%4s%8s%10s%12s%n", "Years", "Principal", "Total", "Gain" );
while (yearCount <= years)
{
gain = principal * (1 + rate / 400);
total = principal + gain;
System.out.printf("%4d%8f%10f%12f%n",years, principal, total, gain);
total= (rate*years)*principal;
yearCount++;
}
{
System.out.print("your total investment is:" + total);
}
}
}