import javax.swing.JOptionPane; public class Airtime { public static void main(String args[]){ double Amount =0; double Duration =0; double CallCostPerMinute =0; boolean goodInput = false; boolean good = false; boolean Good = false; String AmountString=JOptionPane.showInputDialog(null, "Enter the amout of Airtime you have :",JOptionPane.ERROR_MESSAGE); do { try { Amount=Double.parseDouble(AmountString); goodInput = true; } catch (NumberFormatException nfe) { AmountString = JOptionPane.showInputDialog(null, "'"+AmountString+"'" + " is an Invalid Amount"+" Please Enter the correct Amount \nEg. Enter 29.55 for R29.55cents:","Error!",JOptionPane.ERROR_MESSAGE); }