ShortCalculator.java 881B

123456789101112131415161718192021222324252627282930
  1. public class ShortCalculator {
  2. public static void main(String[] args) {
  3. short x = 12121;
  4. short y = 21212;
  5. System.out.println("Sum = " + sum(x, y));
  6. System.out.println("Difference = " + difference(x, y));
  7. System.out.println("Remainder = " + remainder(x, y));
  8. System.out.println("Product = " + product(x, y));
  9. System.out.println("Quotient = " + quotient(x, y));
  10. }
  11. public static short sum(short x, short y) {
  12. return (short)(x + y);
  13. }
  14. public static short difference(short x, short y) {
  15. return (short)(x - y);
  16. }
  17. public static short remainder(short x, short y) {
  18. return (short)(x % y);
  19. }
  20. public static short product(short x, short y) {
  21. return (short)(x * y);
  22. }
  23. public static short quotient(short x, short y) {
  24. return (short)(x / y);
  25. }
  26. }