lundi 18 septembre 2017

JAVA checking characters range with logical operators

I'm in my first Java class, be kind.

what I'd like to do is prompt a user for a valid between 6-10 user id is valid, if not it is invalid. I'm trying to use an if/else with logical operators.I just cant see whats wrong.I have this feeling my problem is right in front of me and I'm just overlooking it. Thanks

import javax.swing.JOptionPane;

public class Lab4 {

    public static void main(String[] args) {

      String input;
      int userID;

      input = JOptionPane.showInputDialog(null,"enter ID");
      userID = Integer.parseInteger(input); //This is where I think my issue is

      if (userID < 10 && userID > 6)
      {
          JOptionPane.showMessageDialog(null, "Welcome, Lynsey14"
          + "\nMy name is Hal");
      }
      else
       { 
          JOptionPane.showMessageDialog(null,"Sorry, user ID is invalid.");
      }

     System.exit(0);      
    }

    }

Aucun commentaire:

Enregistrer un commentaire