123456789101112131415161718192021222324252627282930313233343536373839404142 |
-
- import java.util.*;
-
- public class ShortCalculator {
-
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("Please insert your first number.");
- int x = input.nextInt();
- System.out.println("Please insert your second number.");
-
- int y = input.nextInt();
-
- System.out.println("Adding them equals " + ShortCalculator.sum(x, y));
- System.out.println("Subtracting them equals " + ShortCalculator.difference(x,y));
- System.out.println("Multiplying them equals " + ShortCalculator.product(x,y));
- System.out.println("Dividing them equals " + ShortCalculator.quotient(x, y));
- System.out.println("The remainder between them is " + ShortCalculator.remainder(x,y));
- }
-
- public static Short sum(int x, int y){
- return (short)(x + y);
- }
-
- public static Short difference(int x, int y) {
- return (short)(x - y);
- }
-
- public static Short product(int x, int y) {
- return (short)(x * y);
- }
-
- public static Short quotient(int x, int y) {
- return (short)(x / y);
- }
-
- public static Short remainder(int x, int y) {
- return (short)(x % y);
- }
-
- }
|