Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- private static Scanner scanner = new Scanner(System.in);
- public static void main(String[] args) {
- boolean quit = false;
- int choice = 0;
- int score = 12;
- int guess = 0;
- printActions();
- while(!quit) {
- System.out.println("Choose the option " );
- choice = scanner.nextInt();
- scanner.nextLine();
- switch ((choice)) {
- case 0:
- System.out.println("Shutting down");
- quit = true;
- break;
- case 1:
- System.out.println("Uses a field");
- String answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 2:
- System.out.println("Compass");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 3:
- System.out.println("Attractive");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 4:
- System.out.println("Can be permanent");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 5:
- System.out.println("Makes or wipes data");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 6:
- System.out.println("Horseshoe");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 7:
- System.out.println("Useless if overheated");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 8:
- System.out.println("Often near a coil");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 9:
- System.out.println("Planet earth is one, effectively");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 10:
- System.out.println("Part of a speaker");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 11:
- System.out.println("Poles");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 12:
- System.out.println("Can harm if swallowed");
- answer = scanner.nextLine();
- if (answer.toLowerCase().equals("magnet")) {
- System.out.println("Correct!");
- score--;
- if (guess == 0) {
- score = 12;
- }
- guess++;
- System.out.println("Your score is " + score);
- }
- else {
- System.out.println("Your answer is incorrect. Try choosing another hint.");
- score--;
- guess++;
- }
- break;
- case 13:
- System.out.println("Magnet is the answer!");
- break;
- }
- }
- }
- private static void printActions() {
- System.out.println("\nYou can guess the answer after each hint. The earlier you guess, the more points you get: \nChoose ");
- System.out.println("\t 0 - To quit");
- System.out.println("\t 1 - To print clue number 1");
- System.out.println("\t 2 - To print clue number 2");
- System.out.println("\t 3 - To print clue number 3");
- System.out.println("\t 4 - To print clue number 4");
- System.out.println("\t 5 - To print clue number 5");
- System.out.println("\t 6 - To print clue number 6");
- System.out.println("\t 7 - To print clue number 7");
- System.out.println("\t 8 - To print clue number 8");
- System.out.println("\t 9 - To print clue number 9");
- System.out.println("\t 10 - To print clue number 10");
- System.out.println("\t 11- To print clue number 11");
- System.out.println("\t 12 - To print clue number 12");
- System.out.println("\t 13 - To print the answer");
- System.out.println("=======");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement