Just trying to make a coin flip game, but also trying to make the coin which equals a random number 0 or 1 to convert to a string type "heads" or "tails". New to programming so please don't judge if it seems amateurish. Thank you.
namespace TestCoin2
{
class Program
{
static void Main(string[] args)
{
int coin;// this will hold my random int numbers.
string userInput;// This will hold all my user input/ answers.
Console.WriteLine("Hello, Pick Heads or Tails:");
userInput =Console.ReadLine();
Random rng = new Random();
coin = rng.Next(0, 2);
string myString2;
string myString;
if (coin == 0)
{
myString = coin.ToString("heads");
}
else if (coin == 1)
{
myString2 = coin.ToString("tails"); <error under myString2
}
if (myString && userInput == "heads")
{
Console.WriteLine("You picked Right! Heads! YOU WIN!");
}
else if (coin == 1 && userInput == "Tails")
{
Console.WriteLine("You picked Right! Tails! YOU WIN!");
}
else
{
Console.WriteLine("You picked Wrong! it was..." + myString); <error
}
Console.ReadLine();
}
}
}