Shavit

Simple Add

Oct 8th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class SimpleAdd {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.         char num1, num2;
  13.        
  14.         System.out.println("Enter two digits between 0 and 9:");
  15.         num1 = in.next().charAt(0);
  16.         num2 = in.next().charAt(0);
  17.        
  18.         int n1 = num1 - '0';
  19.         int n2 = num2 - '0';
  20.        
  21.         System.out.printf("Your equation is: %d + %d = %d", n1, n2, n1+n2);
  22.        
  23.         in.close();
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment