Advertisement
Shavit

Twenty Numbers V3

Oct 27th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class TwentyNumbersV3 {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.        
  13.         int num = 0, sum, ones, tens;
  14.        
  15.         System.out.println("Enter 2 digit numbers:");
  16.         num = in.nextInt();
  17.        
  18.         while(num!=-1)
  19.         {
  20.             ones = num%10;
  21.             tens = num/10;
  22.             sum = ones + tens;
  23.             if(ones==tens)
  24.             {
  25.                 num = in.nextInt();
  26.             }
  27.             else
  28.             {
  29.             System.out.printf("%d ", sum);
  30.             num = in.nextInt();
  31.             }
  32.         }
  33.        
  34.         in.close();
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement