Hello, I am fairly new to Java and decided it would be fun to mess around to see what I can do so far. I was wondering if anyone could help me with my problem. I am making a interactive sort of game where you use scanners to take the next course. I have created some code so far but for some reason when I try to confirm the players name it takes both of the scanner I set up already and mashes them into one. I know this might be a bad explanation but if someone could figure out what I mean and help me so that I answer one question at a time that would be great. Thanks.
import java.util.*;
public class fun
{
public static void main (String [] args)
{
Scanner console = new Scanner (System.in);
System.out.println("Hello Traveler, Welcome to THE GAME OF CHANCE!");
System.out.println("My name is Za, Ruler of All. I will be your guide on your journey.");
int start = 0;
while (start == 0)
{
int wait = 1;
System.out.println("Type in your name, it can't be too long and it doesn't have to be your real name so make it a good one.");
String name = console.nextLine();
if (name.equals("your name"))
{
System.out.println ("Oh we have a comedian I see");
}
else if (name.equals("too long"))
{
System.out.println ("Seriously?? I said it can't be 'too long'");
}
else if (name.equals("your real name"))
{
System.out.println ("I said it doesn't have to be 'your real name'");
}
else if (name.equals("a good one"))
{
System.out.println ("That is...not what i meant");
}
else
{
start = 1;
wait = 0;
while(wait == 0)
{
System.out.println ("Your name is " + name + "? (Answer with 'yes' or 'no'");
String yesorno = console.next();
if (yesorno.equals("yes"))
{
System.out.println("Alrighty then " + name + " let's get you on your way");
wait = 1;
}
else if (yesorno.equals("no"))
{
System.out.println("Then what is your name?");
wait = 1;
start = 0;
}
else
{
System.out.println("Invalid input");
wait = 1;
start = 0;
}
}
}
}
}
}