ShortCalculator.java 936B

1234567891011121314151617181920212223242526272829303132
  1. import java.util.Scanner;
  2. public class ShortCalculator {
  3. public static void main(String[] args){
  4. Scanner scanner = new Scanner(System.in);
  5. System.out.println("Please enter a number:");
  6. short num = scanner.nextShort();
  7. System.out.println("Please enter another number:");
  8. short num2 = scanner.nextShort();
  9. short a = (short)(num + num2);
  10. short s = (short)(num - num2);
  11. short m = (short)(num * num2);
  12. short d = (short)(num / num2);
  13. short r = (short)(num % num2);
  14. System.out.println("The sum of x and y: " + a);
  15. System.out.println("The difference of x and y: " + s);
  16. System.out.println("The multiplication of x and y: " + m);
  17. System.out.println("The division of x and y: " + d);
  18. System.out.println("The remainder of x and y: " + r);
  19. }
  20. }