dm6801

20171113 - 03 - classEx_03

Nov 13th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. package myApp;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class class03_ex09 {
  6.  
  7.     public static void main(String[] args) {
  8.         //init vars
  9.         int n = 1;
  10.        
  11.         //open in_stream
  12.         Scanner s = new Scanner(System.in);
  13.        
  14.         //usage info
  15.         System.out.print("Type in XY, where X=Y (ex. 99): ");
  16.        
  17.         /* while left digit does not equal right digit, OR num equals 0, do:
  18.         - accept new n value
  19.         else, continue with the program ;) */
  20.        
  21.         while (n%10 != n/10 || n==0) {
  22.             n = s.nextInt();
  23.         }
  24.                
  25.         //close in_stream
  26.         s.close();
  27.        
  28.         //exit msg
  29.         System.out.printf("number %d accepted. exit..%n", n);
  30.        
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment