fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. {
  14. System.out.println("Make your arithmetic selection from the choices below:\n");
  15. System.out.println(" A. Addition");
  16. System.out.println(" S. Substraction");
  17. System.out.println(" M. Multiplication");
  18. System.out.println(" D. Division");
  19. System.out.println(" E. Exponents\n");
  20.  
  21. Scanner choice = new Scanner(System.in);
  22. String letter = choice.nextLine();
  23. char ch = letter.charAt(0);
  24. System.out.print("Your Choice:" + " " + letter + "\n");
  25.  
  26. System.out.print("\nEnter first number: ");
  27. double op1 = choice.nextDouble();
  28. System.out.println(op1);
  29. System.out.print("\nEnter second number: ");
  30. double op2 = choice.nextDouble();
  31. System.out.println(op2);
  32.  
  33. System.out.println("\n");
  34.  
  35. switch(ch)
  36. {
  37. case 'A':
  38. case 'a':
  39. System.out.println(op1 + " plus " + op2 + " = "+(op1+op2));
  40. break;
  41. case 'S':
  42. case 's':
  43. System.out.println(op1 + " minus " + op2 + " = "+(op1-op2));
  44. break;
  45. case 'M':
  46. case 'm':
  47. System.out.println(op1 + " times " + op2 + " = "+(op1*op2));
  48. break;
  49. case 'D':
  50. case 'd':
  51. System.out.println(op1 + " divided by " + op2 + " = "+(op1/op2));
  52. break;
  53. case 'E':
  54. case 'e':
  55. System.out.println(op1 + " to the power of " + op2 + " = "+ Math.pow(op1, op2));
  56. break;
  57. default:
  58. System.out.println("Not an option! Regard the following options above!");
  59. }
  60. }
  61. }
  62. }
Success #stdin #stdout 0.32s 59424KB
stdin
D.
6
3
stdout
Make your arithmetic selection from the choices below:

  A. Addition
  S. Substraction
  M. Multiplication
  D. Division
  E. Exponents

Your Choice: D.

Enter first number: 6.0

Enter second number: 3.0


6.0 divided by 3.0 = 2.0