- 2
How can i input yes or no in an if statement??
Ex: if(yes){print(let's play);}... this would b for Java..
3 ответов
+ 1
For yes/no, you need to define a string variable.
eg : myvar is a string variable
String myvar="yes";
if(myvar=="yes")
System.out.println("let us play");
else if(myvar=="no")
System.out.println("let us code");
else
System.out.println("Input is not valid");
0
Since one of his tags is boolean I think he want to do it with a boolean. Instead of string myvar="yes";
You can use this code:
bool play = true;
//some logic...
If(play){
//do something
} else {
//do something
}
0
so I have it your way Florian... I would lk for me to input(yes) rather than play..