Thanks everyone, that code works for me =P
And im using Eclipse, (www.eclipse.org)
What im really working towards is the java equivelant of a simple C++ program that i wrote. Does anyone know of anywhere i can host .exe or .zip files so that i can show you guys my program?
OK, eventually i get to asking the user wether they are sure about the time (they answer the time in a earlier question) and i do and if statement to check wether they are sure or not. Here is my full code...
import java.io.*;
public class helloworld {
public static void main(String[] args) {
String name = "";
String age = "";
String time = "";
String sure = "";
try {
System.out.print("Ahh. Hello, what is your name? ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
name = br.readLine();
}
catch (IOException ioe){
System.out.println("Right, thats not working somehow.");
}
System.out.println("Oh, so your name is " + name);
System.out.print("And how old are you? ");
try {
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
age = br.readLine();
}
catch (IOException ioe){
System.out.println("Right, thats not working somehow.");
}
System.out.print("Thats great! You are a whole " + age);
System.out.println(" Years old!");
System.out.print("Im sorry, but would you happen to know the time? ");
try {
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
time = br.readLine();
}
catch (IOException ioe){
System.out.println("Right, thats not working somehow.");
}
System.out.println("Ah, so you think the time is " + time);
System.out.print("Are you sure about that? ");
try {
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
sure = br.readLine();
}
catch (IOException ioe){
System.out.println("Right, thats not working somehow.");
}
-------------------------------------
heres where i think it gets dodgey, theres no errors. But always if you enter yes at the question. It will always print - Right, so your not sure. That's not good... I have tested it at least 5 times just to check if it was me not typing yes in properly =P. But no, its defenitely in the code.
if (sure == "yes"){
System.out.println("Ah, so your sure then. That's good!");
}
else {
System.out.println("Right, so your not sure. That's not good...");
}
}
}
Any suggestions? thank you.