Infexis
Nov 1, 2012, 04:45 AM
I am very new to java and this is my first little program I'm trying to write, it's really simple. However, I've run into a little problem and I don't know how to fix it, any input would be greatly appreciated.
Here's the code:
import java.util.Scanner;
class apples{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.println("Write 'sup' in the console, then press enter, please. " + "\n" );
String sup = input.nextLine();
if (sup.equals("sup" || "Sup"))
{
System.out.println(" dawg." + "\n");
}
else{
System.out.println("\n" + "'" + sup + "'" + "...." + "\n" + "\n" + "Was this was I asked you to write?" + "\n" + "\n" + "Can't follow simple directions, eh?" + "\n");
}
}
}
The problem is the "if (sup.equals("if (sup.equals(" || " || "))" line.
I have no idea how to make it accept both of the "))" and "sup" statements. Help plx :)
Here's the code:
import java.util.Scanner;
class apples{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.println("Write 'sup' in the console, then press enter, please. " + "\n" );
String sup = input.nextLine();
if (sup.equals("sup" || "Sup"))
{
System.out.println(" dawg." + "\n");
}
else{
System.out.println("\n" + "'" + sup + "'" + "...." + "\n" + "\n" + "Was this was I asked you to write?" + "\n" + "\n" + "Can't follow simple directions, eh?" + "\n");
}
}
}
The problem is the "if (sup.equals("if (sup.equals(" || " || "))" line.
I have no idea how to make it accept both of the "))" and "sup" statements. Help plx :)