ShortCalculator.java 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import java.util.*;
  2. public class ShortCalculator {
  3. public static void main(String[] args) {
  4. Scanner input = new Scanner(System.in);
  5. System.out.println("Please insert your first number.");
  6. int x = input.nextInt();
  7. System.out.println("Please insert your second number.");
  8. int y = input.nextInt();
  9. System.out.println("Adding them equals " + ShortCalculator.sum(x, y));
  10. System.out.println("Subtracting them equals " + ShortCalculator.difference(x,y));
  11. System.out.println("Multiplying them equals " + ShortCalculator.product(x,y));
  12. System.out.println("Dividing them equals " + ShortCalculator.quotient(x, y));
  13. System.out.println("The remainder between them is " + ShortCalculator.remainder(x,y));
  14. }
  15. public static Short sum(int x, int y){
  16. return (short)(x + y);
  17. }
  18. public static Short difference(int x, int y) {
  19. return (short)(x - y);
  20. }
  21. public static Short product(int x, int y) {
  22. return (short)(x * y);
  23. }
  24. public static Short quotient(int x, int y) {
  25. return (short)(x / y);
  26. }
  27. public static Short remainder(int x, int y) {
  28. return (short)(x % y);
  29. }
  30. }