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