tags:

views:

107

answers:

1

BEFORE ANYONE SAYS ANYTHING THIS IS NOT (I REPEAT NOT) HOMEWORK

i have a combox and the combo box

try {
    double input = Double.valueOf(input1.getText());
    double output = 0;

my combo box code here:

 if (output < 2.50){
     answerField.setText("£2.50");

         }
         else{
     answerField.setText("£" + String.valueOf (fmt.format(output)));
      catch (Exception e) {    JOptionPane.showMessageDialog(this,
 "Please enter numbers in the fields.
 Numbers are 1 2 3 4 5 etc.",
 "Oooops!!!",
 JOptionPane.ERROR_MESSAGE);
}

the problem i have is that when i run it like this it wont work. if i take the if statement out and leave try catch in it works and also if i take the try and catch out it and leave only the if it also works

when i run it using the above i get this error:

catch without try
; expected

can anyone help?

+1  A: 

you must close your else bracket, and then your try bracket:

try {
  if (..) {
     ...
  } else {
     ...
  }
} catch (Exception e) {..}
Bozho
everything is closed. i've triple checked
Tuffy G
sorry.misunderstood what you said lol.its working now.thank you
Tuffy G