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