Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.93 KB | None | 0 0
  1. public class Main {
  2. private static Scanner scanner = new Scanner(System.in);
  3.     public static void main(String[] args) {
  4.         boolean quit = false;
  5.         int choice = 0;
  6.         int score = 12;
  7.         int guess = 0;
  8.         printActions();
  9.  
  10.         while(!quit) {
  11.             System.out.println("Choose the option " );
  12.             choice = scanner.nextInt();
  13.             scanner.nextLine();
  14.  
  15.             switch ((choice)) {
  16.                 case 0:
  17.                     System.out.println("Shutting down");
  18.                     quit = true;
  19.                     break;
  20.                 case 1:
  21.                     System.out.println("Uses a field");
  22.                     String answer = scanner.nextLine();
  23.                     if (answer.toLowerCase().equals("magnet")) {
  24.                         System.out.println("Correct!");
  25.                         score--;
  26.                         if (guess == 0) {
  27.                             score = 12;
  28.                         }
  29.                         guess++;
  30.                         System.out.println("Your score is " + score);
  31.  
  32.                     }
  33.                     else {
  34.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  35.                         score--;
  36.                         guess++;
  37.                     }
  38.                     break;
  39.                 case 2:
  40.                     System.out.println("Compass");
  41.                     answer = scanner.nextLine();
  42.                     if (answer.toLowerCase().equals("magnet")) {
  43.                         System.out.println("Correct!");
  44.                         score--;
  45.                         if (guess == 0) {
  46.                             score = 12;
  47.                         }
  48.                         guess++;
  49.                         System.out.println("Your score is " + score);
  50.  
  51.                     }
  52.                     else {
  53.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  54.                         score--;
  55.                         guess++;
  56.                     }
  57.                     break;
  58.                 case 3:
  59.                     System.out.println("Attractive");
  60.                     answer = scanner.nextLine();
  61.                     if (answer.toLowerCase().equals("magnet")) {
  62.                         System.out.println("Correct!");
  63.                         score--;
  64.                         if (guess == 0) {
  65.                             score = 12;
  66.                         }
  67.                         guess++;
  68.                         System.out.println("Your score is " + score);
  69.                     }
  70.                     else {
  71.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  72.                         score--;
  73.                         guess++;
  74.                     }
  75.                     break;
  76.                 case 4:
  77.                     System.out.println("Can be permanent");
  78.                     answer = scanner.nextLine();
  79.                     if (answer.toLowerCase().equals("magnet")) {
  80.                         System.out.println("Correct!");
  81.                         score--;
  82.                         if (guess == 0) {
  83.                             score = 12;
  84.                         }
  85.                         guess++;
  86.                         System.out.println("Your score is " + score);
  87.                     }
  88.                     else {
  89.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  90.                         score--;
  91.                         guess++;
  92.                     }
  93.                     break;
  94.                 case 5:
  95.                     System.out.println("Makes or wipes data");
  96.                     answer = scanner.nextLine();
  97.                     if (answer.toLowerCase().equals("magnet")) {
  98.                         System.out.println("Correct!");
  99.                         score--;
  100.                         if (guess == 0) {
  101.                             score = 12;
  102.                         }
  103.                         guess++;
  104.                         System.out.println("Your score is " + score);
  105.                     }
  106.                     else {
  107.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  108.                         score--;
  109.                         guess++;
  110.                     }
  111.                     break;
  112.                 case 6:
  113.                     System.out.println("Horseshoe");
  114.                     answer = scanner.nextLine();
  115.                     if (answer.toLowerCase().equals("magnet")) {
  116.                         System.out.println("Correct!");
  117.                         score--;
  118.                         if (guess == 0) {
  119.                             score = 12;
  120.                         }
  121.                         guess++;
  122.                         System.out.println("Your score is " + score);
  123.                     }
  124.                     else {
  125.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  126.                         score--;
  127.                         guess++;
  128.                     }
  129.                     break;
  130.                 case 7:
  131.                     System.out.println("Useless if overheated");
  132.                     answer = scanner.nextLine();
  133.                     if (answer.toLowerCase().equals("magnet")) {
  134.                         System.out.println("Correct!");
  135.                         score--;
  136.                         if (guess == 0) {
  137.                             score = 12;
  138.                         }
  139.                         guess++;
  140.                         System.out.println("Your score is " + score);
  141.                     }
  142.                     else {
  143.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  144.                         score--;
  145.                         guess++;
  146.                     }
  147.                     break;
  148.                 case 8:
  149.                     System.out.println("Often near a coil");
  150.                     answer = scanner.nextLine();
  151.                     if (answer.toLowerCase().equals("magnet")) {
  152.                         System.out.println("Correct!");
  153.                         score--;
  154.                         if (guess == 0) {
  155.                             score = 12;
  156.                         }
  157.                         guess++;
  158.                         System.out.println("Your score is " + score);
  159.                     }
  160.                     else {
  161.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  162.                         score--;
  163.                         guess++;
  164.                     }
  165.                     break;
  166.                 case 9:
  167.                     System.out.println("Planet earth is one, effectively");
  168.                     answer = scanner.nextLine();
  169.                     if (answer.toLowerCase().equals("magnet")) {
  170.                         System.out.println("Correct!");
  171.                         score--;
  172.                         if (guess == 0) {
  173.                             score = 12;
  174.                         }
  175.                         guess++;
  176.                         System.out.println("Your score is " + score);
  177.                     }
  178.                     else {
  179.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  180.                         score--;
  181.                         guess++;
  182.                     }
  183.                     break;
  184.                 case 10:
  185.                     System.out.println("Part of a speaker");
  186.                     answer = scanner.nextLine();
  187.                     if (answer.toLowerCase().equals("magnet")) {
  188.                         System.out.println("Correct!");
  189.                         score--;
  190.                         if (guess == 0) {
  191.                             score = 12;
  192.                         }
  193.                         guess++;
  194.                         System.out.println("Your score is " + score);
  195.                     }
  196.                     else {
  197.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  198.                         score--;
  199.                         guess++;
  200.                     }
  201.                     break;
  202.                 case 11:
  203.                     System.out.println("Poles");
  204.                     answer = scanner.nextLine();
  205.                     if (answer.toLowerCase().equals("magnet")) {
  206.                         System.out.println("Correct!");
  207.                         score--;
  208.                         if (guess == 0) {
  209.                             score = 12;
  210.                         }
  211.                         guess++;
  212.                         System.out.println("Your score is " + score);
  213.                     }
  214.                     else {
  215.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  216.                         score--;
  217.                         guess++;
  218.                     }
  219.                     break;
  220.                 case 12:
  221.                     System.out.println("Can harm if swallowed");
  222.                     answer = scanner.nextLine();
  223.                     if (answer.toLowerCase().equals("magnet")) {
  224.                         System.out.println("Correct!");
  225.                         score--;
  226.                         if (guess == 0) {
  227.                             score = 12;
  228.                         }
  229.                         guess++;
  230.                         System.out.println("Your score is " + score);
  231.                     }
  232.                     else {
  233.                         System.out.println("Your answer is incorrect. Try choosing another hint.");
  234.                         score--;
  235.                         guess++;
  236.                     }
  237.                     break;
  238.                 case 13:
  239.                     System.out.println("Magnet is the answer!");
  240.                     break;
  241.             }
  242.         }
  243.     }
  244.  
  245.     private static void printActions() {
  246.         System.out.println("\nYou can guess the answer after each hint. The earlier you guess, the more points you get: \nChoose ");
  247.         System.out.println("\t 0 - To quit");
  248.         System.out.println("\t 1 - To print clue number 1");
  249.         System.out.println("\t 2 - To print clue number 2");
  250.         System.out.println("\t 3 - To print clue number 3");
  251.         System.out.println("\t 4 - To print clue number 4");
  252.         System.out.println("\t 5 - To print clue number 5");
  253.         System.out.println("\t 6 - To print clue number 6");
  254.         System.out.println("\t 7 - To print clue number 7");
  255.         System.out.println("\t 8 - To print clue number 8");
  256.         System.out.println("\t 9 - To print clue number 9");
  257.         System.out.println("\t 10 - To print clue number 10");
  258.         System.out.println("\t 11- To print clue number 11");
  259.         System.out.println("\t 12 - To print clue number 12");
  260.         System.out.println("\t 13 - To print the answer");
  261.         System.out.println("=======");
  262.  
  263.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement