Advertisement
Camocc_Studios

ErrorCheckingLoops

Feb 24th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class ErrorCheckingLoops {
  4.     public static void main(String[] args) {
  5.         char a;
  6.         do {
  7.             a = JOptionPane.showInputDialog("enter a lower case letter").charAt(0);
  8.            
  9.         }while((int)a < 97 || (int)a >122);
  10.         System.out.println(a);
  11.        
  12.         int b;
  13.         do {
  14.             b = Integer.parseInt(JOptionPane.showInputDialog("enter a negative int"));
  15.            
  16.         }while(b > -1);
  17.         System.out.println(b);
  18.        
  19.         int c;
  20.         do {
  21.             c = Integer.parseInt(JOptionPane.showInputDialog("enter an even int"));
  22.            
  23.         }while(c%2 != 0);
  24.         System.out.println(c);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement