Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a console program that will work in MS VIsual C# 2010 that will generate a

ID: 3543961 • Letter: W

Question

                    Write a console program that will work in MS VIsual C# 2010 that will generate a random number based on lower and upper range inputs.                 

                            Create a console program where you will implement variables that are needed for this program and will implement the code within Main and any static                             methods that are called.                         

                            The program will take inputs for a range of integer numbers, a low end of the range and a high end of the range. These two integer numbers will be used                             to generate a random number that will be displayed.                         

                            The program will consist of Main and three void methods.                         

                            The first method will request the low number for the range and the high number in the range. It will then pass the two range numbers to a second                             method.                         

                            The second method will take the two numbers passed to it and will generate a random number within the range. It will then pass the two range numbers                             and the random number to the third method.                         

                            The third method will take the three numbers passed to it and display then to the console in the format indicated in the sample output below.                         

                            Main will only have one line of code which will call the first method.                         

                            The first method will call the second method and the second method will call the third.                         

                    You should format your output to look something like the following:                 

Explanation / Answer

Hi


Simple one :


Here how it goes :


class Program

{

  

static void Main()

{

GetRange();   

}


static void GetRange()

{

Console.Write("Enter the low integer range number : ");

int low = int.Parse(Console.ReadLine());

Console.Write("Enter the high integer range number: ");

int high = int.Parse(Console.ReadLine());

GetRandomNumber(low, high);   

}


static void GetRandomNumber(int low, int high)

{

Random rand = new Random();

int number = rand.Next(low, high + 1); // add 1 as method excludes high point

DisplayNumbers(low, high, number);

}


static void DisplayNumbers(int low, int high, int number)

{

Console.WriteLine("random number from range {0} and {1} is {2}", low, high, number);

Console.WriteLine("Press any key to continue...");

Console.ReadKey();

}

}


Any Further Queries Ping me :)


Cheers

Happy Coding

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote