Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Assignment3
  3. {
  4. public static void main(String[] args)
  5. {
  6. Scanner scan = new Scanner(System.in);
  7. System.out.println("Welcome to the Calculator!");
  8. System.out.println("Enter the first operand:");
  9. double firstOperand = scan.nextDouble();
  10. System.out.println("Enter the second operand:");
  11. double secondOperand = scan.nextDouble();
  12. System.out.println("Operations are:");
  13. System.out.println("ADD or + for addition");
  14. System.out.println("SUBTRACT or - for subraction");
  15. System.out.println("MULTIPLY or * for multiplication");
  16. System.out.println("DIVIDE or / for division");
  17. System.out.println("Enter your selection:");
  18. String selection = scan.next();
  19. double ADD = (firstOperand + secondOperand);
  20. double SUBTRACT = (firstOperand - secondOperand);
  21. double MULTIPLY = (firstOperand * secondOperand);
  22. double DIVIDE = (firstOperand / secondOperand);
  23.  
  24. if (selection == ADD)
  25. {
  26. System.out.println("The product is:" + ADD);
  27. }
  28. if (selection == SUBTRACT)
  29. {
  30. System.out.println("The product is:" + SUBTRACT);
  31. }
  32. if (selection == MULTIPLY)
  33. {
  34. System.out.println("The product is:" + MULTIPLY);
  35. }
  36. if (selection == DIVIDE)
  37. {
  38. System.out.println("The product is:" + DIVIDE);
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement