Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the code that I have so far.. I have yet to add the medium and hard roun

ID: 3651378 • Letter: T

Question

This is the code that I have so far.. I have yet to add the medium and hard rounds.. but can anyone please add the lifelines part to this code? such that when the user enters 50:50, 2 of the 4 choices in the question currently being answered will be removed, leaving the user with only 2 choices to choose from, but this can only be done by the player thrice for the whole game then the player must be told that he has no more lifelines left.. I have no idea how to do this.. thanks so much! by the way I am from the Philippines that is why the currency of the game is in Philippine pesos

import java.io.*;
import java.util.*;

class Millionaire
{
private String choice;
private static int counter=0;

public static int moneyCounter()
{
counter = counter+10000;
return(counter);
}

public static void Mechanics()
{
System.out.println(" Mechanics:");
System.out.println("|==========================================================================|");
System.out.println(" The player will be given a set of questions.");
System.out.println(" For each correct answer, ");
System.out.println(" the player's money will automatically increase");
System.out.println(" until he reaches the maximum ");
System.out.println(" amount of 1 Million Pesos.");
System.out.println(" During the game, if the player get a wrong answer, ");
System.out.println(" he will go home with nothing. ");
System.out.println("|===========================================================================|");
System.out.println(" For every correct answer in the easy round, +P10,000. ");
System.out.println(" For every correct answer in the medium round, +P50,000. ");
System.out.println(" For every correct answer in the hard round, +P100,000. ");
System.out.println("|==========================================================================|");

System.out.println(" Lifeline: (Press the ff keys to use lifeline)");
System.out.println("|=========================================================================|");
System.out.println(" You will be given one lifeline: 50:50. ");
System.out.println(" This means 2 of the 4 choices will be removed. ");
System.out.println(" You will have 3 chances to use this lifeline throughout the whole game. ");
System.out.println(" Use it wisely! |");
System.out.println("|==========================================================================|");
}

public static void EasyRound()
{
try
{
System.out.println(" EASY ROUND FIRST!");

BufferedReader fileIn = new BufferedReader(new FileReader("Easy.txt"));
BufferedReader KeyIn = new BufferedReader (new InputStreamReader(System.in));


LinkedList<String> Easy = new LinkedList<String>();

for(int i=0; i<26; i++)
{
//EASY Question
Easy.add(fileIn.readLine());
}


for(int i=0; i<10; i++)
{
System.out.println(" For Php "+moneyCounter()+", here is the question: ");
System.out.println(" Question #"+(i+1)+":");

int R = (int)(26*Math.random());
String Q = Easy.remove(R);

String[] token = Q.split("::");

String question;
question = token[1];

System.out.println(question);
System.out.println(" a) "+token[2]+" b) "+token[3]+" c) "+token[4]+" d) "+token[5]);

//input user's answer
System.out.print(" Answer: ");
String userAns = KeyIn.readLine();

if(userAns.equals(token[6]))
{
System.out.println("Your answer's CORRECT! Next question.");
}
else if(!userAns.equals(token[6]))
{
System.out.println("SORRY, you won't get any prize~ Thank you for trying!");
System.exit(0);
}

}
}//Exception stuff
catch(IndexOutOfBoundsException hehe)
{
System.out.println("There's something wrong.");
}
catch(FileNotFoundException haha)
{
System.out.println("There's something wrong.");
}
catch(IOException hihi)
{
System.out.println("There's something wrong.");
}

}
}

public class WWTBAM
{

public static void main(String[] args) throws Exception
{
BufferedReader KeyIn = new BufferedReader (new InputStreamReader(System.in));
Millionaire A = new Millionaire();

System.out.print("What's your name? ");
String nickName = KeyIn.readLine();

System.out.println(" Welcome to 'Who wants to be a Millionaire?' Game!");

System.out.println("Would you like to know the mechanics?");
System.out.println("[n] for no [y] for yes.");
System.out.print("User: ");
String ansMech = KeyIn.readLine();

if(ansMech.equals("y"))
{
A.Mechanics();

}
if(!ansMech.equals("n"))
{
System.out.println(" NOW LET'S START!");
}

//Start the game~
System.out.println("|==========================================================================|");
//This is where the questions will be given, etc.

A.EasyRound();

System.out.println(" |==========================================================================|");




}
}

Explanation / Answer

//WWTBAM.java //run the program :D //input ff for lifeline option import java.io.*; import java.util.*; class Millionaire { private String choice; private static int counter = 0; private static int lifeline = 3; public static int moneyCounter() { counter = counter + 10000; return (counter); } public static void Mechanics() { System.out.println(" Mechanics:"); System.out .println("|==========================================================================|"); System.out.println(" The player will be given a set of questions."); System.out.println(" For each correct answer, "); System.out.println(" the player's money will automatically increase"); System.out.println(" until he reaches the maximum "); System.out.println(" amount of 1 Million Pesos."); System.out .println(" During the game, if the player get a wrong answer, "); System.out.println(" he will go home with nothing. "); System.out .println("|===========================================================================|"); System.out .println(" For every correct answer in the easy round, +P10,000. "); System.out .println(" For every correct answer in the medium round, +P50,000. "); System.out .println(" For every correct answer in the hard round, +P100,000. "); System.out .println("|==========================================================================|"); System.out .println(" Lifeline: (Press the ff keys to use lifeline)"); System.out .println("|=========================================================================|"); System.out.println(" You will be given one lifeline: 50:50. "); System.out .println(" This means 2 of the 4 choices will be removed. "); System.out .println(" You will have 3 chances to use this lifeline throughout the whole game. "); System.out.println(" Use it wisely! |"); System.out .println("|==========================================================================|"); } public static void EasyRound() { try { System.out.println(" EASY ROUND FIRST!"); BufferedReader fileIn = new BufferedReader(new FileReader( "Easy.txt")); BufferedReader KeyIn = new BufferedReader(new InputStreamReader( System.in)); LinkedList Easy = new LinkedList(); for (int i = 0; i < 26; i++) { // EASY Question Easy.add(fileIn.readLine()); } for (int i = 0; i < 10; i++) { System.out.println(" For Php " + moneyCounter() + ", here is the question: "); System.out.println(" Question #" + (i + 1) + ":"); int R = (int) (26 * Math.random()); String Q = Easy.remove(R); String[] token = Q.split("::"); String question; question = token[1]; System.out.println(question); System.out.println(" a) " + token[2] + " b) " + token[3] + " c) " + token[4] + " d) " + token[5]); // input user's answer System.out.print(" Answer: "); String userAns = KeyIn.readLine(); if (userAns.equals("ff")){ if(lifeline == 0){ System.out.println("Sorry, You have used up all 3 lifeline chances."); }else{ int removed = 0; for(int j=0;j
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote