Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java help

  • 28-11-2015 04: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, Registered Users 2 Posts: 1,720 ✭✭✭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