ShortCalculator.java 844B

1234567891011121314151617181920212223242526272829
  1. import java.util.*;
  2. public class ShortCalculator {
  3. public static void main(String[] args){
  4. {
  5. Short a,b,sum,diff,pro,quo,rem;
  6. Scanner input= new Scanner(System.in);
  7. System.out.printf("\nEnter first number");
  8. a=input.nextShort();
  9. System.out.printf("\nEnter second number");
  10. b=input.nextShort();
  11. sum=(short)(a+b);
  12. diff=(short)(a-b);
  13. pro=(short)(a*b);
  14. quo=(short)(a/b);
  15. rem=(short)(a%b);
  16. System.out.printf("\nSum is %d",sum);
  17. System.out.printf("\nDifference is :%d",diff);
  18. System.out.printf("\nProduct is :%d",pro);
  19. System.out.printf("\nQuotient is :%d",quo);
  20. System.out.printf("\nThe remainder is :%d",rem);
  21. }
  22. }
  23. }