ShortCalculator.java 542B

12345678910111213141516171819202122232425262728293031323334
  1. public class ShortCalculator {
  2. short x;
  3. short y;
  4. public ShortCalculator (short x, short y){
  5. this.x = x;
  6. this.y = y;
  7. }
  8. public short getSum(){
  9. return (short) (x + y);
  10. }
  11. public short getDifference() {
  12. return (short) (x - y);
  13. }
  14. public short getProduct() {
  15. return (short) (x * y);
  16. }
  17. public short getQuotient() {
  18. return (short) (x / y);
  19. }
  20. public short getRemainder() {
  21. return (short) (x % y);
  22. }
  23. }