ShortCalculator.java 703B

12345678910111213141516171819202122232425262728293031323334353637
  1. import java.util.Scanner;
  2. public class ShortCalculator {
  3. private short n1;
  4. private short n2;
  5. public ShortCalculator(short x, short y) {
  6. this.n1 = x;
  7. this.n2 = y;
  8. }
  9. public short sum() {
  10. return (short) (n1 + n2);
  11. }
  12. public short difference() {
  13. return (short) (n1 - n2);
  14. }
  15. public short product() {
  16. return (short) (n1 * n2);
  17. }
  18. public short quotient() {
  19. return (short) (n1 / n2);
  20. }
  21. public short remainder() {
  22. return (short) (n1 % n2);
  23. }
  24. public void printLine(String operation, short value) {
  25. System.out.println(operation + ": " + value);
  26. }
  27. }