Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class TwentyNumbersV3 {
- public static void main(String[] args)
- {
- Scanner in = new Scanner (System.in);
- int num = 0, sum, ones, tens;
- System.out.println("Enter 2 digit numbers:");
- num = in.nextInt();
- while(num!=-1)
- {
- ones = num%10;
- tens = num/10;
- sum = ones + tens;
- if(ones==tens)
- {
- num = in.nextInt();
- }
- else
- {
- System.out.printf("%d ", sum);
- num = in.nextInt();
- }
- }
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement