Hi im writing a very "simple" program in C# for a console app..
I'm supposed to make a program that asks a user how many dice to roll, rolls a six sided die that many times, and returns the total and average roll.(this is all coming out of a book "C# programming for absolute beginners")
I cant figure how to get the value of the dice roll outside of the for statement please help.
I'm supposed to make a program that asks a user how many dice to roll, rolls a six sided die that many times, and returns the total and average roll.(this is all coming out of a book "C# programming for absolute beginners")
I cant figure how to get the value of the dice roll outside of the for statement please help.
Code:
{
class Program
{
static void Main(string[] args)
{
Random generator = new Random();
int NumberOfRolls;
Console.WriteLine("how many dice should i roll?");
NumberOfRolls = int.Parse(Console.ReadLine());
for (int i = 0; i < NumberOfRolls; i++)
{
double mydouble = (int)(generator.NextDouble() * 6) + 1;
int total = +(int)mydouble;
double average = total / NumberOfRolls;
Console.WriteLine(average);
}
}
}
}
Comment