fork(1) 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. System.out.println("Make your arithmetic selection from the choices below:\n");
  13. System.out.println(" A. Addition");
  14. System.out.println(" S. Substraction");
  15. System.out.println(" M. Multiplication");
  16. System.out.println(" D. Division");
  17. System.out.println(" E. Exponents\n");
  18.  
  19. Scanner choice = new Scanner(System.in);
  20. String letter = choice.nextLine();
  21. char ch = letter.charAt(0);
  22. System.out.print("Your Choice:" + " " + letter + "\n");
  23.  
  24. System.out.print("\nEnter first number: ");
  25. double op1 = choice.nextDouble();
  26. System.out.println(op1);
  27. System.out.print("\nEnter second number: ");
  28. double op2 = choice.nextDouble();
  29. System.out.println(op2);
  30.  
  31. System.out.println("\n");
  32.  
  33. switch(ch)
  34. {
  35. case 'A':
  36. case 'a':
  37. System.out.println(op1 + " plus " + op2 + " = "+(op1+op2));
  38. break;
  39. case 'S':
  40. case 's':
  41. System.out.println(op1 + " minus " + op2 + " = "+(op1-op2));
  42. break;
  43. case 'M':
  44. case 'm':
  45. System.out.println(op1 + " times " + op2 + " = "+(op1*op2));
  46. break;
  47. case 'D':
  48. case 'd':
  49. System.out.println(op1 + " divided by " + op2 + " = "+(op1/op2));
  50. break;
  51. case 'E':
  52. case 'e':
  53. System.out.println(op1 + " to the power of " + op2 + " = "+ Math.pow(op1, op2));
  54. break;
  55. default:
  56. System.out.println("Not an option! Regard the following options above!");
  57. }
  58.  
  59. }
  60. }
Success #stdin #stdout 0.21s 61284KB
stdin
A
1
3
stdout
Make your arithmetic selection from the choices below:

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

Your Choice: A

Enter first number: 1.0

Enter second number: 3.0


1.0 plus 3.0 = 4.0