Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- class WWBAMIsaac{
- public static void main(String args[]){
- int fiftyfiftyval = 1; // do while condition of 50/50 loop
- String fiftyyesno; // user's response to use 50/50 or not
- int friend = 1; // do while condition of phone a friend loop
- String friendyesno; // user's response to use phone a friend or not
- int audience = 1; // do while condition of ask the audience loop
- String audienceyesno; // user's response to call the audience or not'
- String input = "test";
- int i = 0;
- String[] arrayQuestionAnswers = new String [13]; // Array for 13 questions and 4 answers
- arrayQuestionAnswers[0] = "What year was The Beatles founded? \n" + "A.1960 \n" + "B.1956 \n" + "C.1972 \n" + "D.1965 \n";
- arrayQuestionAnswers[1] = "What is Freddie Mercury best known for? \n" + "A. He was the lead singer of Queen \n" + "B. He was a jazz singer \n" + "C. He was a classical musician \n" + "D.He assassinated the Queen \n";
- arrayQuestionAnswers[2] = "Which famous artist is often referred to ?The King of Rock and Roll?? \n" + "A. Elvis Presley \n" + "B. Prince \n" + "C.Michael Jackson \n" + "D. Freddie Mercury \n";
- arrayQuestionAnswers[3] = "What band was Michael Jackson part of in his early ages? \n" + "A. The Jacksons \n" + "B. The Jackson 5 \n" + "C. 5 Jacksons \n" + "D. The 5 \n";
- arrayQuestionAnswers[4] = "What song is the line: ?Let me see what spring is like on Jupiter and Mars.? from? \n" + "A. Fly Me to the Moon ? Frank Sinatra \n" + "B. Starman ? David Bowie \n" + "C. Don?t Stop Me Now ? Queen \n" + "D. Life On Mars? ? David Bowie \n";
- arrayQuestionAnswers[5] = "?Stairway to Heaven? was by: \n" + "A. Led Zeppelin \n" + "B. Queen \n" + "C. The Beatles \n" + "D. Metallica \n";
- arrayQuestionAnswers[6] = "What was the cause of John Lennon?s death? \n" + "A. Cancer \n" + "B. Heart Attack \n" + "C. Assasination \n" + "D.Car Crash \n";
- arrayQuestionAnswers[7] = "What nationality was ?The Eagles?? \n" + "A. English \n" + "B. American \n" + "C. Scottish \n" + "D. Canadian \n";
- arrayQuestionAnswers[8] = "Who was the lead singer of ?Nirvana?? \n" + "A. George Michael \n" + "B. Paul McCartney \n" + "C. Jimmy Hendrix \n" + "D. Kurt Cobain \n";
- arrayQuestionAnswers[9] = "How did Elvis die? \n" + "A. Heart Attack \n" + "B. Diabetes \n" + "C. HIV/AIDS \n" + "D. Cancer \n";
- arrayQuestionAnswers[10]= "True or False, Michael Jackson had vitiligo. (skin pigmentation) \n" + "A. True \n" + "B. False \n" + "C. Vitiligo is not a real disease \n " + "D. Vitiligo does not happen to people with dark skin \n";
- arrayQuestionAnswers[11]= "What year did George Michael die? \n" + "A. 2014" + "B. 2015" + "C. 2016" + "D. 2017";
- arrayQuestionAnswers[12]= "What year was ABBA founded? \n" + "A. 1972 \n" + "B. 1970 \n" + "C. 1973 \n" + "D. 1975 \n";
- String[] arrayAnswer = new String [13]; //Array for the 13 correct asnwers
- arrayAnswer[0] = "A";
- arrayAnswer[1] = "A";
- arrayAnswer[2] = "A";
- arrayAnswer[3] = "B";
- arrayAnswer[4] = "A";
- arrayAnswer[5] = "A";
- arrayAnswer[6] = "C";
- arrayAnswer[7] = "B";
- arrayAnswer[8] = "D";
- arrayAnswer[9] = "A";
- arrayAnswer[10]= "A";
- arrayAnswer[11]= "C";
- arrayAnswer[12]= "A";
- String[] arrayAnswerLifeline = new String [13]; //Array for 13 modified questions and answers for 50/50
- arrayAnswerLifeline[0] = "What year was The Beatles founded? \n" + "A.1960 \n" + "C.1972 \n";
- arrayAnswerLifeline[1] = "What is Freddie Mercury best known for? \n" + "A. He was the lead singer of Queen \n" + "B. He was a jazz singer \n";
- arrayAnswerLifeline[2] = "Which famous artist is often referred to ?The King of Rock and Roll?? \n" + "A. Elvis Presley \n" + "D. Freddie Mercury \n";
- arrayAnswerLifeline[3] = "What band was Michael Jackson part of in his early ages? \n" + "B. The Jackson 5 \n" + "C. 5 Jacksons \n";
- arrayAnswerLifeline[4] = "What song is the line: ?Let me see what spring is like on Jupiter and Mars.? from? \n" + "A. Fly Me to the Moon ? Frank Sinatra \n" + "D.Life On Mars? ? David Bowie \n";
- arrayAnswerLifeline[5] = "?Stairway to Heaven? was by: \n" + "A. Led Zeppelin \n" + "C. The Beatles \n";
- arrayAnswerLifeline[6] = "What was the cause of John Lennon?s death? \n" + "A. Cancer \n" + "C. Assasination \n";
- arrayAnswerLifeline[7] = "What nationality was ?The Eagles?? \n" + "A. English \n" + "B. American \n";
- arrayAnswerLifeline[8] = "Who was the lead singer of ?Nirvana?? \n" + "C. Jimmy Hendrix \n" + "D. Kurt Cobain \n";
- arrayAnswerLifeline[9] = "How did Elvis die? \n" + "A. Heart Attack \n" + "C. HIV/AIDS \n";
- arrayAnswerLifeline[10]= "True or False, Michael Jackson had vitiligo. (skin pigmentation) \n" + "A. True \n" + "B. False \n";
- arrayAnswerLifeline[11]= "What year did George Michael die? \n" + "A. 2014" + "C. 2016";
- arrayAnswerLifeline[12]= "What year was ABBA founded? \n" + "A. 1972 \n" + "D. 1975 \n";
- int[] arrayWages = new int [13]; //Array for the different wages
- arrayWages[0] = 100;
- arrayWages[1] = 200;
- arrayWages[2] = 500;
- arrayWages[3] = 1000;
- arrayWages[4] = 2000;
- arrayWages[5] = 5000;
- arrayWages[6] = 10000;
- arrayWages[7] = 20000;
- arrayWages[8] = 50000;
- arrayWages[9] = 100000;
- arrayWages[10] = 200000;
- arrayWages[11] = 500000;
- arrayWages[12] = 1000000;
- String name; //variable to store user's name
- String userAnswer = ""; //Variable to store user's response to each question
- int exitvalue = 1; //condition for do-while loop
- String userYesNo = ""; //Variable to store user's response to continue game or not
- int totalwage = 0; //Variable to store total wage
- Scanner scan = new Scanner(System.in);
- Random randomPhone = new Random();
- Random randomAudience = new Random();
- System.out.println ("Hello! Please enter your name.");
- name = scan.nextLine ();
- System.out.println ("Welcome, " + name + ", to Who Wants to be a Millionaire.");
- System.out.println ("The game is simple. The game is divided into three difficulty levels. \n" + "Answer a question correctly, you get a monetary reward. \n" + "You will be given the choice to continue or claim your reward. \n" + "But if you answer incorrectly, you will only get your reward if you reached a checkpoint. Otherwise, you lose everything. \n" + "Good luck.");
- do {
- System.out.println (arrayQuestionAnswers[i]);
- System.out.println ("Would you like to use lifeline perk: 50/50, phoneafriend, or asktheaudience");
- System.out.println("If you do not want to use a lifeline, please input 'answer'.");
- input = scan.nextLine ();
- if (input.equalsIgnoreCase("50/50") && fiftyfiftyval == 1) {
- fiftyfiftyval = 0;
- System.out.println (arrayAnswerLifeline[i]);
- System.out.println ("Please enter: 'A','B','C', or 'D'");
- userAnswer = scan.nextLine();
- if (userAnswer.equalsIgnoreCase(arrayAnswer[i])) {
- System.out.println ("Correct!");
- totalwage = arrayWages[i];
- System.out.println ("You currently have: $" + totalwage + ".");
- System.out.println ("Do you want to continue? Yes(y) or no(n)?");
- userYesNo = scan.nextLine ();
- if (userYesNo.equals("y")) {
- exitvalue = 1;
- } else if (userYesNo.equals("n")) {
- exitvalue = 0;
- }
- } else if (userAnswer != arrayAnswer [i]) {
- System.out.println("Incorrect! You lost!");
- exitvalue = 0;
- }
- } else if (input.equalsIgnoreCase("50/50") && fiftyfiftyval == 0) {
- System.out.println("You've already used this lifeline");
- i--;
- }
- if (input.equalsIgnoreCase("phoneafriend") && friend == 1) {
- friend = 0;
- int friendrandom = randomPhone.nextInt(100) + 1;
- if (friendrandom <= 80) {
- System.out.println ("Correct!");
- totalwage = arrayWages[i];
- System.out.println ("You currently have: $" + totalwage + ".");
- System.out.println ("Do you want to continue? Yes(y) or no(n)?");
- userYesNo = scan.nextLine ();
- if (userYesNo.equals("y")) {
- exitvalue = 1;
- } else if (userYesNo.equals("n")) {
- exitvalue = 0;
- }
- } else if (friendrandom <= 100) {
- System.out.println("Incorrect! You lost!");
- exitvalue = 0;
- }
- } else if (input.equalsIgnoreCase("phoneafriend") && friend == 0) {
- System.out.println("You've already used this lifeline");
- i--;
- }
- if (input.equalsIgnoreCase("asktheaudience") && audience == 1) {
- audience = 0;
- int audiencerandom = randomAudience.nextInt(100) + 1;
- if (audiencerandom <= 40) {
- System.out.println ("Correct!");
- totalwage = arrayWages[i];
- System.out.println ("You currently have: $" + totalwage + ".");
- System.out.println ("Do you want to continue? Yes(y) or no(n)?");
- userYesNo = scan.nextLine ();
- if (userYesNo.equals("y")) {
- exitvalue = 1;
- } else if (userYesNo.equals("n")) {
- exitvalue = 0;
- }
- } else if (audiencerandom <= 100){
- System.out.println("Incorrect! You lost!");
- exitvalue = 0;
- }
- } else if (input.equalsIgnoreCase("asktheaudience") && audience == 0) {
- System.out.println("You've already used this lifeline");
- i--;
- }
- if (input.equalsIgnoreCase("answer")) {
- System.out.println (arrayQuestionAnswers[i]);
- System.out.println ("Please enter: 'A','B','C', or 'D'");
- userAnswer = scan.nextLine();
- if (userAnswer.equalsIgnoreCase(arrayAnswer[i])) {
- System.out.println ("Correct!");
- totalwage = arrayWages[i];
- System.out.println ("You currently have: $" + totalwage + ".");
- System.out.println ("Do you want to continue? Yes(y) or no(n)?");
- userYesNo = scan.nextLine ();
- if (userYesNo.equals("y")) {
- exitvalue = 1;
- } else if (userYesNo.equals("n")) {
- exitvalue = 0;
- }
- } else if (userAnswer != arrayAnswer [i]) {
- System.out.println("Incorrect! You lost!");
- exitvalue = 0;
- }
- }
- if (!input.equalsIgnoreCase("") && (!input.equalsIgnoreCase("50/50")) && (!input.equalsIgnoreCase("phoneafriend")) && (!input.equalsIgnoreCase("asktheaudience")) && (!input.equalsIgnoreCase("answer"))) {
- System.out.println("Please try again.");
- i--;
- }
- i++;
- } while (exitvalue == 1);
- if (i == 13) {
- System.out.println("Congrats");
- } else {
- System.out.println("Sucks to suck. At least you got: " + totalwage);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement