All pastes #2063980 Raw Edit

Stuff

public text v1 · immutable
#2063980 ·published 2011-05-19 01:06 UTC
rendered paste body
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class project
{
public static void main(String args[]) throws IOException
{
for(int q=0;q<1;q++) //A loop that allows the game to be restarted. the integer q will be decremented if the user wants to restart.
{
Scanner questions = new Scanner(new File("C:\\Documents and Settings\\13_pangle.cody\\Desktop\\Questions.in"));
Scanner answers = new Scanner(new File("C:\\Documents and Settings\\13_pangle.cody\\Desktop\\Answers.in"));
Scanner solutions = new Scanner(new File("C:\\Documents and Settings\\13_pangle.cody\\Desktop\\Solution.in"));
double money[]={100,200,300,500,1000,2000,4000,8000,16000,25000,50000,100000,250000,500000,750000,1000000}; //Money Values


int maxIndx = -1;
int maxInd = -1;
int maxIn = -1;

String quest[] = new String[100];
String answ[] = new String[100];
String solu[] = new String[100];
Scanner bb = new Scanner(System.in);
Scanner kbReader = new Scanner(System.in); 
boolean haslost=false;
int count = 0;
while(questions.hasNext())
{
for(int k = 0; k<2; k++)
{
int j;
maxIndx++;
quest[maxIndx] = questions.nextLine();
System.out.println(quest[k]);
System.out.println("");
{
maxInd++;
answ[maxInd] = answers.nextLine();
System.out.println(answ[k]);
System.out.println("");
}
{
maxIn++;
solu[maxIn] = solutions.nextLine();
}

System.out.println("Please choose your answer.");
String answer = kbReader.nextLine();
System.out.println("");
count++;
if(answer.equalsIgnoreCase(solu[k])) 
{
System.out.println("Congratulations! You've got the answer correct.");
System.out.print("You have $"+money[count -1]+".");
System.out.println("");
continue;
}
else
{
System.out.println("Sorry you answered the question incorrect.");
haslost=true;
break;
}
}
if(haslost==true)
break;
}
questions.close();


for(boolean b=true;b==true //Infinite loop. Will be broken/continued later 
{
System.out.print("Do you wish to play again? (Y/N): ");
String playagain=bb.nextLine().toUpperCase(); //Play again input
if(playagain.equals("Y")) //If you typed in a y...
{
q--; //decrements q for the biggest loop so it can run on
System.out.print('\u000C');//Clears the screen
break; //breaks the current loop
}
else if(playagain.equals("N")) // if you type in a n
{
System.out.print("Thanks For Playing");
break; //Ends game
}
else //If you type in anything but a Y or N...
{
System.out.println("You need to enter a Y or N");
continue; //Goes to the top of the infinite loop
}
}
}
}