Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

input closes why?

$
0
0
When I run my program and enter in the data for age as a letter it closes?

I am using a do while loop to validate the age to ensure the input is between 0-120 and is a number.

I ran my program and entered the first time for testing purposes
125

The input dialog box opened again asking for age so i tried typing

hs

and the whole input dialog box closes.

Where did I go wrong?

    
        //panel2 age  input dialog
         do
         {
         strInput = JOptionPane.showInputDialog(null, "Enter the persons "
                 + "age.");
         age = Integer.parseInt(strInput);
        
         //validate age entry between 0-120  input dialog
         }
         while(age < 0 || age > 120 || strInput.isEmpty());{
           JOptionPane.showMessageDialog(null, "Please enter an age between "
                   + "0 and 120!");
      }
          

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>