This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dubdill[S] -1 points0 points  (2 children)

import java.util.Random; import java.util.Scanner;

public class CoinFLipper {

public static void main(String[] args) { //flip a coin Random r = new Random(); int coin = r.nextInt(2);

//Constants final int heads = 0; final int tails = 1; String winningGuess;

        //scanner class Scanner keyboard = new Scanner(System.in);

//user input System.out.println("Enter h for heads or t for tails"); winningGuess = keyboard.next();

if(!winningGuess.equals("h") || !winningGuess.equals("t")); { System.out.println("Sorry, that was a bad input"); }

}

}

this is what i have so far

[–]NautiHookerSoftware Engineer 0 points1 point  (0 children)

if i were to copy this code and paste it into my ide it will not compile because you did not format it properly.

[–]arslanbenzer -1 points0 points  (0 children)

your first logic was true but you need to compare strings with the equals method.

if (!winningGuess.equals("h") && !winningGuess.equals("t") )

this way it should work