0

I am having problems with it continuous loop at the end of the program. Any help would be appreciated. Thank you. Below is the coding so far.

```
import static java.lang.System.out;
import java.util.Scanner;
import java.io.*;
public class Investment {
public static void main(String[] args) {
double principal = 0;
double interest = 0;
double rate = 0.05;
int years = 0;
double goal = 0;
double total = 0;
Scanner myScanner = new Scanner(System.in);
// Welcome message
System.out.println("Welcome to the Investment Calculator.");
// Enter initial amount
System.out.println ("Enter your initial investment amount. If you want to exit enter 0.");
int input1 = myScanner.nextInt();
principal = input1;
// Decision for exit
if (input1 == 0){
System.exit(0);
}
// Enter goal amount
System.out.println ("Enter your goal investment amount: ");
int input2 = myScanner.nextInt ();
goal = input2;
System.out.println ("The fixed interest rate is 5%");
// Loop to get total years
total= principal;
total= (interest+1)*total;
for (years=0; total < goal; years++){
System.out.print("The number of years you must invest to meet your goal of $ " + goal + " is " + years + " years.");
}
}
}
```

*Edited 6 Years Ago by Krazykado*: n/a