i really appreciate if someone can help me ,below is my source code

i need modify my source code with this, try catch , to check if user input letter then error message pop outQuote:

int goal,again , ask;

final double INITIAL_SALES = 0.00;

double monthly_sales =0;

ask = JOptionPane.showConfirmDialog (null, "Do you wish to start Sales amount program ? ");

do

{

if(ask == JOptionPane.YES_OPTION){

String base_salary_string = JOptionPane.showInputDialog("please enter your base salary (RM): ");

int base_salary = Integer.parseInt(base_salary_string);

String initial_goalString = JOptionPane.showInputDialog("please enter your goal (RM) (in one year, 12 months): ");

int initial_goal = Integer.parseInt(initial_goalString);

String min_sales2String = JOptionPane.showInputDialog("please enter minumum of sales for 10 % commission (RM): ");

double min_sales2 = Double.parseDouble(min_sales2String);

String min_sales3String = JOptionPane.showInputDialog("please enter minimum of sales for 12 % commission (RM): ");

double min_sales3 = Double.parseDouble(min_sales3String);

goal= initial_goal - base_salary; //actual goal is initial goal - salary

double Commission = 0; //initilize commission to 0

double salesAmount = INITIAL_SALES;

do {

// Increase salesAmount by 1 cent

salesAmount += 0.01;

if (salesAmount >= min_sales3) //minimum sales which will get 12% commision rate

Commission = (base_salary * 0.08) + (base_salary * 0.1) + ((salesAmount - 10000) * 0.12);

else if

(salesAmount >= min_sales2) //minimum sales which will get 10% commision rate

Commission = (base_salary * 0.08) + ((salesAmount - 5000) * 0.10);

else

Commission = salesAmount * 0.08; // 8% commision rate

} while (Commission <goal);

monthly_sales = salesAmount /12; // sales amount are divide into 12 months

String output=String.format("\nThe sales amount RM %.2f is required to make a commision of RM %d\nmonthly sales amount is needed to make is RM %.2f ", salesAmount, goal, monthly_sales);

JOptionPane.showMessageDialog(null, output);

}

ask = JOptionPane.showConfirmDialog (null, "Wish to continue ?");

}

while (ask == JOptionPane.YES_OPTION);

}

}

but after i modified it , because it seem error occur that here , the symbol of base salary cant be found , please tell me how do i correct this thing , i am beginner (Ps: the highlighted is modify code )Quote:

String base_salary_string = JOptionPane.showInputDialog("please enter your base salary (RM): ");

try

{

int base_salary = Integer.parseInt(base_salary_string);

}

// If base_salary isn't an int, it calls a NumberFormatException

catch (NumberFormatException e)

{

JOptionPane.showMessageDialog(null, "you have entered invalid data");

}

Quote:

int goal,again , ask;

final double INITIAL_SALES = 0.00;

double monthly_sales =0;

ask = JOptionPane.showConfirmDialog (null, "Do you wish to start Sales amount program ? ");

do

{

if(ask == JOptionPane.YES_OPTION){

String base_salary_string = JOptionPane.showInputDialog("please enter your base salary (RM): ");

try

{

int base_salary = Integer.parseInt(base_salary_string);

}

// If base_salary isn't an int, it calls a NumberFormatException

catch (NumberFormatException e)

{

JOptionPane.showMessageDialog(null, "you have entered invalid data");

}

String initial_goalString = JOptionPane.showInputDialog("please enter your goal (RM) (in one year, 12 months): ");

int initial_goal = Integer.parseInt(initial_goalString);

String min_sales2String = JOptionPane.showInputDialog("please enter minumum of sales for 10 % commission (RM): ");

double min_sales2 = Double.parseDouble(min_sales2String);

String min_sales3String = JOptionPane.showInputDialog("please enter minimum of sales for 12 % commission (RM): ");

double min_sales3 = Double.parseDouble(min_sales3String);

goal= initial_goal - base_salary; //actual goal is initial goal - salary

double Commission = 0; //initilize commission to 0

double salesAmount = INITIAL_SALES;

do {

// Increase salesAmount by 1 cent

salesAmount += 0.01;

if (salesAmount >= min_sales3) //minimum sales which will get 12% commision rate

Commission = (base_salary * 0.08) + (base_salary * 0.1) + ((salesAmount - 10000) * 0.12);

else if

(salesAmount >= min_sales2) //minimum sales which will get 10% commision rate

Commission = (base_salary * 0.08) + ((salesAmount - 5000) * 0.10);

else

Commission = salesAmount * 0.08; // 8% commision rate

} while (Commission <goal);

monthly_sales = salesAmount /12; // sales amount are divide into 12 months

String output=String.format("\nThe sales amount RM %.2f is required to make a commision of RM %d\nmonthly sales amount is needed to make is RM %.2f ", salesAmount, goal, monthly_sales);

JOptionPane.showMessageDialog(null, output);

}

ask = JOptionPane.showConfirmDialog (null, "Wish to continue ?");

}

while (ask == JOptionPane.YES_OPTION);

}}