Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How can I make Java recognize "yes"

$
0
0
Hello here's my code
import java.util.Scanner;
public class Quest {
public static void main(String[] args){
	
	Scanner ui = new Scanner(System.in);
	int a=1,b=2;
	System.out.println("You have come across a troll! Do you kill it? Press 1 to fight the troll");
	a=ui.nextInt();
	if(a==1){
		System.out.println("You have killed it!");
		
	}
	
	else
		System.out.println("you lost");
	
	
	
	
	
	
	
	
}
}


I want user to enter the word "Yes" instead of 1, How do I achieve this?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>