Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java help

Options
  • 28-11-2015 4:39pm
    #1
    Closed Accounts Posts: 191 ✭✭


    int count =1;
    int even ;
    int odd ;



    while (count <=5){
    String posNum = JOptionPane.showInputDialog("Enter a possitive value or -1 to quit");
    odd = Integer.parseInt(posNum);
    if (odd %2 !=0)
    JOptionPane.showMessageDialog(null,"The number is odd");
    else

    if (even %2 ==0)
    JOptionPane.showMessageDialog(null, "The number is even");
    count++;

    }

    JOptionPane.showMessageDialog(null, "The amount of even numbers is " + even);
    }
    }

    Hey, does anyone know why there is an error and it won't run? Thank you


Comments

  • Registered Users Posts: 1,702 ✭✭✭wiz569


    I know feck all about java etc but would it be the curly braces at the end,you have two closed ones but no corresponding open ones?


  • Closed Accounts Posts: 191 ✭✭chocolate boy123


    No, my error is on the Int even in my if statement! I'm trying to figure out why! Thanks anyway


Advertisement