I just started using Java yesterday. I've tried researching but didn't find anything I could make use of. The problem is that no matter what I type as an Input the program always outputs "Hell" and "Hello fmdas". I think I should write the if (BetOrPlay != "Bet");
Line as else if (BetOrPlay != "Bet");
But the program doesn't allow me to do that.
import java.util.Scanner;
public class MoneyMaker
{
static Scanner Choice = new Scanner (System.in);
public static void main(String[] args)
{
System.out.println("Do you want to bet your coins or earn more by playing this game?");
try
{
if (Choice.hasNextLine())
{
String BetOrPlay = Choice.nextLine();
if (BetOrPlay == "Bet");
{
System.out.println("Hell");
}
if (BetOrPlay != "Bet");
{
System.out.println("Hello fmdas");
}
}
}
finally
{
Choice.close();
}
}
}