loop "play again" in an 8 ball game , loops but wont let me answer my "out.print"
Hey this is my first post so if i make a mistake shout at me.
I made an 8ball program but the problem is when it loops is wont let me answer my "out.print("What would u like to ask ? ");" , it just gives me a yes , no or maybe , then asks "out.println("Want to ask another question ?");"
Iv only been learning code for 3 or 4 days so not very good at it xD:frusty:
Im guessing i need a break; somewhere or another loop ?
heres the code
Code:
import java.util.Scanner;
import static java.lang.System.out;
import java.util.Random;
class TestFor8Ball {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
char reply = 'y';
Random myRandom = new Random();
int random;
while (reply == 'y' || reply == 'Y')
{
out.print("What would u like to ask ? ");
in.nextLine();
out.println();
random = myRandom.nextInt(10) + 1;
if ( random > 5) {
out.println("The answer to your question is No");
} else if (random < 5) {
out.println("The answer to your question is Yes");
} else {
out.println("mmm Maybe i realy dont know");
}
out.println();
out.println("Want to ask another question ?");
out.println();
reply = in.findInLine(".").charAt(0);
if (reply == 'n' || reply == 'N')
{
out.println();
out.println("Good Bye");
}
}
}
}
Re: loop "play again" in an 8 ball game , loops but wont let me answer my "out.print"
This thread could not be responded to owing to a known forum bug arising out of the word 'print" appearing in the thread topic.
I have re-posted it for you here:
http://www.java-forums.org/new-java/...iaresmart.html
db