ShortCalculator.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import java.util.Scanner;
  2. public class ShortCalculator {
  3. public static short S1;
  4. public static short S2;
  5. public static short sum;
  6. public static short diff;
  7. public static short product;
  8. public static short quotient;
  9. public static short remainder;
  10. public static void ShortCalculator(){
  11. Scanner scanner = new Scanner(System.in);
  12. System.out.println("Enter your first Short: ");
  13. S1 = scanner.nextShort();
  14. System.out.println("Enter your Second Short: ");
  15. S2 = scanner.nextShort();
  16. System.out.println(S1);
  17. System.out.println(S2);
  18. sum = (short) (S1 + S2);
  19. diff = (short) (S1 - S2);
  20. product = (short) (S1 * S2);
  21. quotient = (short) (S1 / S2);
  22. remainder = (short) (S1 % S2);
  23. System.out.println("Sum is " + sum);
  24. System.out.println("Diff is " + diff);
  25. System.out.println("Product is " + product);
  26. System.out.println("Quotient is " + quotient);
  27. System.out.println("Remainder is " + remainder);
  28. }
  29. }