RunCalculator.java 1.2KB

12345678910111213141516171819202122232425262728
  1. import java.util.Scanner;
  2. public class RunCalculator{
  3. public static void main (String[] args){
  4. ShortCalculator shortCalculator = new ShortCalculator();
  5. Scanner in = new Scanner (System.in);
  6. System.out.println("Enter a number between 0 and 65535");
  7. short numberOne = in.nextShort();
  8. while(numberOne < 0 || numberOne > 65535){
  9. System.out.println("Enter a number between 0 and 65535");
  10. numberOne = in.nextShort();
  11. }
  12. System.out.println("Enter another number between 0 and 65535");
  13. short numberTwo = in.nextShort();
  14. while(numberTwo < 0 || numberTwo > 65535){
  15. System.out.println("Enter another number between 0 and 65535");
  16. numberTwo = in.nextShort();
  17. }
  18. System.out.println("Sum: " + shortCalculator.sum(numberOne, numberTwo));
  19. System.out.println("Difference: "+ shortCalculator.difference(numberOne, numberTwo));
  20. System.out.println("Product: "+ shortCalculator.product(numberOne, numberTwo));
  21. System.out.println("Quotient :" + shortCalculator.quotient(numberOne, numberTwo));
  22. System.out.println("Remainder: " + shortCalculator.remainder(numberOne, numberTwo));
  23. }
  24. }