//I replace the IF statement I have, or add another? The goal is to just get the response to say Goodbye
//when I type Exit or exit. Right now it responds the same as when I type in any string.
//I read the input, do the output, but maybe only then test for "exit"?
//Would I be better off with a While loop vs a Do While Loop?
//TOTALLY Confused.
/**
Homework assignment that prompts for user input
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Homework1{
public static void main(String[] args){
BufferedReader dataIn = new BufferedReader(new
InputStreamReader(System.in));
String name ="";
do
{
System.out.print("Hi, what's your name?");
try{
name = dataIn.readLine();
if(!(name.compareToIgnoreCase("quit")==0));
System.out.println(name + " it's so nice to meet you");
}
catch(IOException e)
{
System.out.println("error");
}
}while(!(name.compareToIgnoreCase("exit")==0));
System.out.println("Goodbye!");
}
}
This post has been edited by binarimon: 19 January 2009 - 05:09 PM

New Topic/Question
Reply




MultiQuote






|