Ok, I have modified it more, and now I am going crazy because I can't see what I am doing wrong. I am sure that it is a bracket or something somewhere, but Ihave been here for 3 hours and I am not getting anywhere. This is what it is suppose to do.
ask if you like cookies
if yes --> do you like chocolate if yes --> you must like oreo cookies then. if no --> you must like peanut butter. end this section and continue with do you like milk, otherwise if you don't like cookies ---> do you like milk if yes ---> do you like chocolate milk if yes --> me and you both pal. if no --> I don't understand you, goodbye.
it compiles, but when I get to the do you like milk section, it doesn't allow me to answer it, and says me and you too pal. when asks me if i like oreo cookies, if I say no it says ok, so you don't like milk.
Any ideas?
import java.io.*;
class ModifiedTest_Tester
{
public static void main(String args[]) throws IOException
{
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
String strInput;
String strInput1;
System.out.println("Do you like cookies?:");
strInput = dataIn.readLine(); //reads data from console
try
{
if ("y".equals(strInput))
{
System.out.println("Do you like chocolate?:");
strInput = dataIn.readLine(); //reads data from console
if ("y".equals(strInput))
{
System.out.println("You must like Oreo cookies then");
}
else if ("n".equals(strInput))
{
System.out.println("If you don't like Chocolate, you must like peanut butter");
}
else
{
throw new TheException(); //calls
}
}
if ("n".equals(strInput))
System.out.println("Do you like Milk?:");
strInput1 = dataIn.readLine(); //reads data from console
if ("y".equals(strInput1))
{
System.out.println("Do you like Chocolate Milk?");
if ("y".equals(strInput1))
{
System.out.println("Me and you both Pal, put er' their!!");
}
else if ("n".equals(strInput1))
{
System.out.println("I don't Understand you, goodbye!!");
}
else
{
throw new TheException(); //calls
}
}
else if ("n".equals(strInput1))
{
System.out.println("Ok, so you don't like milk, your too picky!!!");
}
else
{
throw new TheException(); //calls
}
}
catch (TheException e)
{
System.out.println("Illegal input caught, please enter a Y or N");
}
System.out.println();
System.out.println("Program Ending!");
}
}