ShortCalculator.java 914B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. public class ShortCalculator {
  2. public void calculator(short x, short y){
  3. add(x,y);
  4. subtract(x,y);
  5. multiply(x,y);
  6. divide(x,y);
  7. remainder(x,y);
  8. }
  9. public short add(short a, short b){
  10. return (short)(a+b);
  11. }
  12. public short subtract(short a, short b){
  13. return (short)(a-b);
  14. }
  15. public short multiply(short a, short b){
  16. return (short)(a*b);
  17. }
  18. public short divide(short a, short b){
  19. return (short)(a/b);
  20. }
  21. public short remainder(short a, short b){
  22. return (short)(a%b);
  23. }
  24. /*
  25. * Write a program that reads in two numbers between 0 and 65535,
  26. * stores them in short variables, and computes their unsigned sum,
  27. * difference, product, quotient, and remainder ,
  28. * without converting them to int.
  29. */
  30. }