Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.15 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3. class WWBAMIsaac{
  4. public static void main(String args[]){
  5. int fiftyfiftyval = 1; // do while condition of 50/50 loop
  6. String fiftyyesno; // user's response to use 50/50 or not
  7. int friend = 1; // do while condition of phone a friend loop
  8. String friendyesno; // user's response to use phone a friend or not
  9. int audience = 1; // do while condition of ask the audience loop
  10. String audienceyesno; // user's response to call the audience or not'
  11. String input = "test";
  12. int i = 0;
  13.  
  14. String[] arrayQuestionAnswers = new String [13]; // Array for 13 questions and 4 answers
  15. arrayQuestionAnswers[0] = "What year was The Beatles founded? \n" + "A.1960 \n" + "B.1956 \n" + "C.1972 \n" + "D.1965 \n";
  16. 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";
  17. 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";
  18.  
  19. 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";
  20. 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";
  21. arrayQuestionAnswers[5] = "?Stairway to Heaven? was by: \n" + "A. Led Zeppelin \n" + "B. Queen \n" + "C. The Beatles \n" + "D. Metallica \n";
  22. 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";
  23. arrayQuestionAnswers[7] = "What nationality was ?The Eagles?? \n" + "A. English \n" + "B. American \n" + "C. Scottish \n" + "D. Canadian \n";
  24.  
  25. 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";
  26. arrayQuestionAnswers[9] = "How did Elvis die? \n" + "A. Heart Attack \n" + "B. Diabetes \n" + "C. HIV/AIDS \n" + "D. Cancer \n";
  27. 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";
  28. arrayQuestionAnswers[11]= "What year did George Michael die? \n" + "A. 2014" + "B. 2015" + "C. 2016" + "D. 2017";
  29. arrayQuestionAnswers[12]= "What year was ABBA founded? \n" + "A. 1972 \n" + "B. 1970 \n" + "C. 1973 \n" + "D. 1975 \n";
  30.  
  31.  
  32. String[] arrayAnswer = new String [13]; //Array for the 13 correct asnwers
  33. arrayAnswer[0] = "A";
  34. arrayAnswer[1] = "A";
  35. arrayAnswer[2] = "A";
  36.  
  37. arrayAnswer[3] = "B";
  38. arrayAnswer[4] = "A";
  39. arrayAnswer[5] = "A";
  40. arrayAnswer[6] = "C";
  41. arrayAnswer[7] = "B";
  42.  
  43. arrayAnswer[8] = "D";
  44. arrayAnswer[9] = "A";
  45. arrayAnswer[10]= "A";
  46. arrayAnswer[11]= "C";
  47. arrayAnswer[12]= "A";
  48.  
  49.  
  50. String[] arrayAnswerLifeline = new String [13]; //Array for 13 modified questions and answers for 50/50
  51. arrayAnswerLifeline[0] = "What year was The Beatles founded? \n" + "A.1960 \n" + "C.1972 \n";
  52. 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";
  53. arrayAnswerLifeline[2] = "Which famous artist is often referred to ?The King of Rock and Roll?? \n" + "A. Elvis Presley \n" + "D. Freddie Mercury \n";
  54.  
  55. arrayAnswerLifeline[3] = "What band was Michael Jackson part of in his early ages? \n" + "B. The Jackson 5 \n" + "C. 5 Jacksons \n";
  56. 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";
  57. arrayAnswerLifeline[5] = "?Stairway to Heaven? was by: \n" + "A. Led Zeppelin \n" + "C. The Beatles \n";
  58. arrayAnswerLifeline[6] = "What was the cause of John Lennon?s death? \n" + "A. Cancer \n" + "C. Assasination \n";
  59. arrayAnswerLifeline[7] = "What nationality was ?The Eagles?? \n" + "A. English \n" + "B. American \n";
  60.  
  61. arrayAnswerLifeline[8] = "Who was the lead singer of ?Nirvana?? \n" + "C. Jimmy Hendrix \n" + "D. Kurt Cobain \n";
  62. arrayAnswerLifeline[9] = "How did Elvis die? \n" + "A. Heart Attack \n" + "C. HIV/AIDS \n";
  63. arrayAnswerLifeline[10]= "True or False, Michael Jackson had vitiligo. (skin pigmentation) \n" + "A. True \n" + "B. False \n";
  64. arrayAnswerLifeline[11]= "What year did George Michael die? \n" + "A. 2014" + "C. 2016";
  65. arrayAnswerLifeline[12]= "What year was ABBA founded? \n" + "A. 1972 \n" + "D. 1975 \n";
  66.  
  67. int[] arrayWages = new int [13]; //Array for the different wages
  68. arrayWages[0] = 100;
  69. arrayWages[1] = 200;
  70. arrayWages[2] = 500;
  71. arrayWages[3] = 1000;
  72. arrayWages[4] = 2000;
  73. arrayWages[5] = 5000;
  74. arrayWages[6] = 10000;
  75. arrayWages[7] = 20000;
  76. arrayWages[8] = 50000;
  77. arrayWages[9] = 100000;
  78. arrayWages[10] = 200000;
  79. arrayWages[11] = 500000;
  80. arrayWages[12] = 1000000;
  81.  
  82. String name; //variable to store user's name
  83. String userAnswer = ""; //Variable to store user's response to each question
  84. int exitvalue = 1; //condition for do-while loop
  85. String userYesNo = ""; //Variable to store user's response to continue game or not
  86. int totalwage = 0; //Variable to store total wage
  87.  
  88.  
  89. Scanner scan = new Scanner(System.in);
  90. Random randomPhone = new Random();
  91. Random randomAudience = new Random();
  92.  
  93. System.out.println ("Hello! Please enter your name.");
  94. name = scan.nextLine ();
  95.  
  96. System.out.println ("Welcome, " + name + ", to Who Wants to be a Millionaire.");
  97. 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.");
  98.  
  99. do {
  100.  
  101. System.out.println (arrayQuestionAnswers[i]);
  102.  
  103. System.out.println ("Would you like to use lifeline perk: 50/50, phoneafriend, or asktheaudience");
  104. System.out.println("If you do not want to use a lifeline, please input 'answer'.");
  105. input = scan.nextLine ();
  106.  
  107. if (input.equalsIgnoreCase("50/50") && fiftyfiftyval == 1) {
  108. fiftyfiftyval = 0;
  109. System.out.println (arrayAnswerLifeline[i]);
  110. System.out.println ("Please enter: 'A','B','C', or 'D'");
  111. userAnswer = scan.nextLine();
  112. if (userAnswer.equalsIgnoreCase(arrayAnswer[i])) {
  113. System.out.println ("Correct!");
  114. totalwage = arrayWages[i];
  115. System.out.println ("You currently have: $" + totalwage + ".");
  116. System.out.println ("Do you want to continue? Yes(y) or no(n)?");
  117. userYesNo = scan.nextLine ();
  118. if (userYesNo.equals("y")) {
  119. exitvalue = 1;
  120. } else if (userYesNo.equals("n")) {
  121. exitvalue = 0;
  122. }
  123. } else if (userAnswer != arrayAnswer [i]) {
  124. System.out.println("Incorrect! You lost!");
  125. exitvalue = 0;
  126. }
  127. } else if (input.equalsIgnoreCase("50/50") && fiftyfiftyval == 0) {
  128. System.out.println("You've already used this lifeline");
  129. i--;
  130. }
  131.  
  132. if (input.equalsIgnoreCase("phoneafriend") && friend == 1) {
  133. friend = 0;
  134. int friendrandom = randomPhone.nextInt(100) + 1;
  135. if (friendrandom <= 80) {
  136. System.out.println ("Correct!");
  137. totalwage = arrayWages[i];
  138. System.out.println ("You currently have: $" + totalwage + ".");
  139. System.out.println ("Do you want to continue? Yes(y) or no(n)?");
  140. userYesNo = scan.nextLine ();
  141. if (userYesNo.equals("y")) {
  142. exitvalue = 1;
  143. } else if (userYesNo.equals("n")) {
  144. exitvalue = 0;
  145. }
  146. } else if (friendrandom <= 100) {
  147. System.out.println("Incorrect! You lost!");
  148. exitvalue = 0;
  149. }
  150. } else if (input.equalsIgnoreCase("phoneafriend") && friend == 0) {
  151. System.out.println("You've already used this lifeline");
  152. i--;
  153. }
  154.  
  155. if (input.equalsIgnoreCase("asktheaudience") && audience == 1) {
  156. audience = 0;
  157. int audiencerandom = randomAudience.nextInt(100) + 1;
  158. if (audiencerandom <= 40) {
  159. System.out.println ("Correct!");
  160. totalwage = arrayWages[i];
  161. System.out.println ("You currently have: $" + totalwage + ".");
  162. System.out.println ("Do you want to continue? Yes(y) or no(n)?");
  163. userYesNo = scan.nextLine ();
  164. if (userYesNo.equals("y")) {
  165. exitvalue = 1;
  166. } else if (userYesNo.equals("n")) {
  167. exitvalue = 0;
  168. }
  169. } else if (audiencerandom <= 100){
  170. System.out.println("Incorrect! You lost!");
  171. exitvalue = 0;
  172. }
  173. } else if (input.equalsIgnoreCase("asktheaudience") && audience == 0) {
  174. System.out.println("You've already used this lifeline");
  175. i--;
  176. }
  177.  
  178. if (input.equalsIgnoreCase("answer")) {
  179. System.out.println (arrayQuestionAnswers[i]);
  180. System.out.println ("Please enter: 'A','B','C', or 'D'");
  181. userAnswer = scan.nextLine();
  182. if (userAnswer.equalsIgnoreCase(arrayAnswer[i])) {
  183. System.out.println ("Correct!");
  184. totalwage = arrayWages[i];
  185. System.out.println ("You currently have: $" + totalwage + ".");
  186. System.out.println ("Do you want to continue? Yes(y) or no(n)?");
  187. userYesNo = scan.nextLine ();
  188. if (userYesNo.equals("y")) {
  189. exitvalue = 1;
  190. } else if (userYesNo.equals("n")) {
  191. exitvalue = 0;
  192. }
  193. } else if (userAnswer != arrayAnswer [i]) {
  194. System.out.println("Incorrect! You lost!");
  195. exitvalue = 0;
  196. }
  197. }
  198. if (!input.equalsIgnoreCase("") && (!input.equalsIgnoreCase("50/50")) && (!input.equalsIgnoreCase("phoneafriend")) && (!input.equalsIgnoreCase("asktheaudience")) && (!input.equalsIgnoreCase("answer"))) {
  199. System.out.println("Please try again.");
  200. i--;
  201. }
  202. i++;
  203. } while (exitvalue == 1);
  204. if (i == 13) {
  205. System.out.println("Congrats");
  206. } else {
  207. System.out.println("Sucks to suck. At least you got: " + totalwage);
  208. }
  209. }
  210.  
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement