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.  
  13. Scanner input = new Scanner(System.in);
  14. System.out.print("How much do you weigh on these planets?");
  15. double earthWeight = input.nextDouble();
  16. int choice = input.nextInt();
  17.  
  18. System.out.println("\n1. Giant Gas Golf Ball");
  19. System.out.println("2. Big Gumball");
  20. System.out.println("3. The Floating Rock that Rocks");
  21. System.out.println("4. Orange Orbiter");
  22. System.out.print("\nEnter you weight and a number to find out!");
  23.  
  24. double newWeight = 0;
  25. String planet = "";
  26.  
  27. switch(choice)
  28. {
  29.  
  30. case 1:
  31. planet = "Giant Gas Golf Ball";
  32. newWeight = earthWeight * 0.5;
  33. break;
  34.  
  35. case 2:
  36. planet = "Big Gumball";
  37. newWeight = earthWeight * 0.25;
  38. break;
  39.  
  40. case 3:
  41. planet = "The Floating Rock that Rocks";
  42. newWeight = earthWeight * 1.5;
  43. break;
  44.  
  45. case 4:
  46. planet = "Orange Orbiter";
  47. newWeight = earthWeight * 2.5;
  48. break;
  49.  
  50. default:
  51. System.out.println("Invalid selection. Enter 1,2,3, or 4.");
  52. System.exit(0);
  53. }
  54.  
  55. System.out.println("\nOn " + planet + ", you weigh " + newWeight + " pounds.");
  56. }
  57. }
Success #stdin #stdout 0.24s 61160KB
stdin
100.5
2
stdout
How much do you weigh on these planets?
1. Giant Gas Golf Ball
2. Big Gumball
3. The Floating Rock that Rocks
4. Orange Orbiter

Enter you weight and a number to find out!
On Big Gumball, you weigh 25.125 pounds.