Guest User

Untitled

a guest
Jun 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using CodeKicker.BBCode;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string userResponse;
  14.             int die1, die2;
  15.             const int MAXROLL = 6;
  16.  
  17.             do
  18.             {
  19.                 Console.WriteLine("Do you want to roll the dice?");
  20.                 Console.WriteLine("Please enter Yes or No");
  21.                 userResponse = Console.ReadLine();
  22.  
  23.                 if (userResponse.ToUpper() == "YES")
  24.                 {
  25.                     Random randomNums = new Random();
  26.  
  27.                     die1 = randomNums.Next(1, MAXROLL + 1);
  28.                     die2 = randomNums.Next(1, MAXROLL + 1);
  29.                     Console.WriteLine("You rolled {0} and {1}", die1, die2);
  30.  
  31.                     if (die1 == MAXROLL && die2 == MAXROLL)
  32.                     {
  33.                         Console.WriteLine("You rolled Boxcars!");
  34.                     }
  35.  
  36.                     if (die1 == 1 && die2 == 1)
  37.                     {
  38.                         Console.WriteLine("You rolled Snake-eyes!");
  39.                     }
  40.                 }
  41.                 else if (userResponse.ToUpper() != "NO")
  42.                 {
  43.                     Console.WriteLine("You must answer YES or NO.");
  44.                 }
  45.                 Console.WriteLine();
  46.  
  47.             } while (userResponse.ToUpper() != "NO");
  48.  
  49.             Console.WriteLine("Goodbye");
  50.  
  51.             Console.ReadLine();
  52.         }
  53.     }
  54. }
Add Comment
Please, Sign In to add comment