using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Random_Number_Generator_In_Range
{
public partial class Form1 : Form
{
int number;
void random()
{
for (int count = 0; count < 20; count++)
{
Random rnd = new Random();
number = rnd.Next(49) + 1;
MessageBox.Show(number.ToString());
if (number == 0 || number <= 24)
{
}
else
{
}
}
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
random();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
}
}
Hello Everyone
This is my first ever post on Stack Overflow so if there are any issues with my question, please let me know so it can help me going forward.
So I have done a little bit of C++ programming, however, now I'm working through some tutorial questions within C# (Windows Application Form) but my knowledge is very limited.
The tutorial questions asks:
- Write a program that will generate 20 random integers in the range 0-49. The program should count and report how many were in the range 0-24 and how many were in the range 25-49. The Form should have one button labelled “Run Simulation” and two labels used to display the results of the simulation. The button and labels should be suitably labelled.
First and foremost, I'm not even sure if I'm on the right track or not, but I am not sure how to print the numbers 0-24 in label 1 and numbers 25-49 into label 2. I have created an if/else statement as I'm sure the instruction I need to enter should go into them but I can't for the life of me think what it would be.
Hopefully this is clear and any assistance would be appreciated.