Please don't bash me for I am new to Java. I am learning but am lost on a simple problem I'm sure. We have been working with a basic text editor and getting our results to show up on the consel. No problem. Now with little knowledge we are supposed to get our code to show up in dialog boxes using import javax.swing.JOptionPane; I have tried many time and been reading online on how to do it but I keep getting all sorts of errors. The book i have does not talk much about JOption. So I went back and put my code back to what I had originally. My code is posted below and any help would be much appreciated. Like I said, I am new and still learning but have been stuck here for a few days getting confused after reading all sorts of stuff online. Thanks in advance! I also want to try and be able to enter a interest rate and have it display in the last message but that is giving me trouble too.
import javax.swing.JOptionPane;
import java.util.Scanner;
public class RetirementGoal2
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int year;
double money;
do {
System.out.print("Enter number of years before retirement: ");
year = sc.nextInt();
System.out.print("Enter annual amount of money: ");
money = sc.nextDouble();
if (year < 1 || money <= 0)
{
System.out.println();
System.out.println("ERROR: Invalid input. Enter new values again.");
System.out.println();
}
}
while (year < 1 || money <= 0);
for (int x = 1; x <= year; x++)
{
for (int y = 0; y < x; y++)
money += money * 0.05;
}
System.out.println();
System.out.println("You will have $" + money +
" at retirement.");
}
}