Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CoinFlip
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. Random rng = new Random();
  15. Console.WriteLine(@"
  16.  
  17. This program will allow you to guess heads or tails on a coin flip.
  18.  
  19. Please enter h for heads, or t for tails and press Enter: ");
  20.  
  21. char userGuess = (char)Console.Read();
  22. int coin = rng.Next(0,2);
  23.  
  24. Console.WriteLine("Coin is {0}nn", coin);
  25.  
  26.  
  27. if (coin == 0 && (userGuess == 'h' || userGuess == 'H'))
  28. {
  29.  
  30. Console.WriteLine("It's heads! You win!");
  31.  
  32. }
  33. else if (coin == 1 && (userGuess == 't' || userGuess == 'T'))
  34. {
  35. Console.WriteLine("It's tails! You win!");
  36.  
  37. }
  38. else if (userGuess != 't' && userGuess != 'T' && userGuess != 'h' && userGuess != 'H')
  39. {
  40. Console.WriteLine("You dumb mofo, you didn't enter a valid letter");
  41. }
  42.  
  43. else
  44. {
  45.  
  46. if (coin == 0) { Console.WriteLine("You lose mofo. The coin was heads!"); }
  47. if (coin == 1) { Console.WriteLine("You lose mofo. The coin was tails!"); }
  48.  
  49. }
  50. Console.ReadLine();
  51. //Console.ReadLine();
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement