ShortCalculator.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import java.util.*;
  2. public class ShortCalculator {
  3. public static void main(String[] args){
  4. Scanner kb = new Scanner(System.in);
  5. System.out.println("Please enter two numbers between 1 - 65525:");
  6. int x = kb.nextInt();
  7. int y = kb.nextInt();
  8. ShortCalculator.add(x,y);
  9. ShortCalculator.subtract(x,y);
  10. ShortCalculator.multiply(x,y);
  11. ShortCalculator.divide(x,y);
  12. ShortCalculator.modulus(x,y);
  13. }
  14. public static Short add(int x, int y){
  15. System.out.println("Your numbers sum: " + (short)(x+y));
  16. return (short)(x+y);
  17. }
  18. public static Short subtract(int x, int y){
  19. System.out.println("Your numbers difference: " + (short)(x-y));
  20. return (short)(x-y);
  21. }
  22. public static Short multiply(int x,int y){
  23. System.out.println("Your numbers multiplied: "+ (short)(x*y));
  24. return (short)(x*y);
  25. }
  26. public static Short divide(int x,int y){
  27. System.out.println("Your numbers divided: " + (short)(x/y));
  28. return (short)(x/y);
  29. }
  30. public static Short modulus(int x,int y){
  31. System.out.println("Your numbers modulus is: " + (short)(x%y));
  32. return (short)(x%y);
  33. }
  34. }