Hey everyone,
This is my first ever programming project, and I am having trouble taking a user's input from JOptionPane and turning it into a working double variable.
In every place that the word "input" comes up, there is an error message (in Eclipse) saying that the variable cannot be resolved (sadly, I don't know exactly what this means either). Also, because of theerror in the beginning, I haven't quite worked out the ending of it either, so just ignore that...
I hope I am overlooking something simple, but this has been giving me a big headache for the past couple of days. I appreciate the help. Thanks.
CODE
import javax.swing.JOptionPane;
public class InvoiceApp {
/**
* @param args
*/
public static void main(String[] args) {
//display a welcome message
JOptionPane.showMessageDialog(null, "Welcome to the Invoice Application");
//perform calculations until choice is not "Y"
String choice = "y";
while (choice.equalsIgnoreCase("y"));
{
//get invoice sub total from the user
input = JOptionPane.showInputDialog(null,"Please Enter Subtotal: ");
double subTotal = Double.parseDouble(input);
//calculate the discount amount and total
double discountPercent = 0.0;
if (subTotal >= 200)
discountPercent = .2;
else if (subTotal >= 100)
discountPercent = .1;
else
discountPercent = 0.0;
double discountAmount = subTotal * discountPercent;
double total = subTotal - discountAmount;
//display the discount amount and total
JOptionPane.showMessageDialog(null, "Discount Percent: " + discountPercent);
JOptionPane.showMessageDialog(null, "Discount Amount: " + discountAmount);
JOptionPane.showMessageDialog(null, "Invoice Total: " + total);
//see if the user wants to continue
String decision = "";
input = JOptionPane.showInputDialog(null, "Would you like to continue?");
}
}
}