class Class1
{
[STAThread]
static void Main(string[] args)
{
int lap, avg = 0;
double time = 0;
Random generator = new Random();
time = generator.Next(5, 10);
for (lap = 1; lap <= 10; lap++)
{
time = (generator.NextDouble())* 10 + 1;
Console.WriteLine("Lap {0} with a lap time of {1} seconds!!!!"lap,time.ToString("##.00"));
}// end for
Console.WriteLine("The total time it took is {0}",time);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Slap the enter key to continue");
Console.ReadLine();
}
}
}
I'm trying to teach myself c#, however this problem really has me baffled. How do i add the time variable each time through the loop to get the sum of all ten laps? any help would be appreciated thanks :)