C# – 3 – Dice Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DiceProgram
{
class DiceProgram
{
static void Main(string[] args)
{
int guess;
string middleMan;
Console.WriteLine(“Welcome to the Kurosh’s dice program”);
Random random = new Random();

for (int i = 0; i < 200; i++)
{
int die = (int)((random.NextDouble() * 6) + 1);
Console.WriteLine("Computer has generated a random number from 0 – 6");
Console.Write("Try to guess the number on the dice: ");
middleMan = Console.ReadLine();
guess = int.Parse(middleMan);
if (guess == die)
{
Console.WriteLine("You have guessed correctly! The number of the dice was {0}", guess);
}
else if (guess != die)
{
Console.WriteLine("Your guess was wrong! You typed {0} but the computer generated number was {1}", guess, die);
}
Console.WriteLine();
}
}
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s