Question

In: Computer Science

Create a random number generator object named myRandom and an integer variable named intRoulette. Set intRoulette...

Create a random number generator object named myRandom and an integer variable named intRoulette. Set intRoulette to be a random number from 0 to 36 (including the numbers 0 and 36). (visual studios 2015) using tryparse

Solutions

Expert Solution

Below is the C# code where random number is generated in betwee to 36 (including the numbers 0 and 36).

Added comments in the code for better understanding.

using System;

class Program
{
    static void Main()
    {
        //Create random number generated object myRandom 
        Random myRandom = new Random();
        
        //int intRoulette variable
        int intRoulette;
        
        //myRandom.Next(0, 37) will generate random number in between 0-36. 
        //0 and 36 both inclusive. As max range is 37 so 37 will be included.
        //out intRoulette will assign generated random number to intRoulette
        //Int32.TryParse accepts first parameter as string so converting generated random number to string 
        //if tryParse succeeds then intRoulette will have correct value of random number between 0 and 36
        if(Int32.TryParse(myRandom.Next(0, 37).ToString(), out intRoulette))
        {
            //Print the number set to intRoulette
            Console.WriteLine("Random number set to intRoulette is : " +intRoulette);
        }
        Console.ReadLine();
    }
}

Belos is the output screenshot


Related Solutions

Use Random number generator (under Data Analysis) to simulate the following data set. Create 10 columns,...
Use Random number generator (under Data Analysis) to simulate the following data set. Create 10 columns, each 20 points long and use the following parameters: Number of variables (10), number of data point (20), Distribution (Normal), Mean (40), Standard Deviation (10), Random seed (1234). The data should be in columns: A,B,C,….,I,J. Randomly pick two columns (say Column B and Column H) and perform 2-sided t-test on these two data columns. Record the P-value and repeat this procedure several times (at...
Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named...
Using C# Create a class named Inches To Feet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method displays inches in feet and inches. For example, 67 inches is 5 feet 7 inches.
Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to...
Create a class using C# named InchesToFeet. Its Main()method holds an integer variable named inches to which you will assign a value. Create a method to which you pass inches. The method uses 2 ref parameters: feet, inches left of type int and a parameter that is not ref of type int to which you pass inchesinches. For example, 67 inches is 5 feet 7 inches.
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a...
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a doubleannual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fields. Write an application named DemoSalesperson that declares an array of 10 Salesperson objects. Set each ID number to 9999 and each sales value to zero. Display the 10 Salesperson objects. public class DemoSalesperson { public static void...
In C++ Create a dynamic array of 100 integer values named myNums. Use a pointer variable...
In C++ Create a dynamic array of 100 integer values named myNums. Use a pointer variable (like ptr) which points to this array. Use this pointer variable to initialize the myNums array from 2 to 200 and then display the array elements. Delete the dynamic array myNums at the end. You just need to write part of the program.
continuous random variable and uniform distribution please follow the comment. A random number generator spits out...
continuous random variable and uniform distribution please follow the comment. A random number generator spits out a random real number in the range [1,4] assume each number is equally likely being out. what is the probability that the model output an irrational number? the answer is 1, but i don't understand
Using C++. Please number the answers for clarity 1. Create an Account object named as myAccount...
Using C++. Please number the answers for clarity 1. Create an Account object named as myAccount and initialize it with appropriate data. 2. Change myAccount’s interest rate to 1% 3. display the balance on myAccount. 4. Declare a pointer variable ptr and initialize it with the address of myAccount. Display the interest earned on myAccount by using pointer ptr. 5. Dynamically allocate an array of five Account objects. 6. Suppose  getAcctNum() returns the account number of a given Account variable.  Write a...
I am trying to create an 8-bit random number generator in verilog code using a mux,...
I am trying to create an 8-bit random number generator in verilog code using a mux, a d flip flop and a LFSR not sure what I am doing wrong but need some help with getting it working properly any help would be greatly appreciated. here is what I have so far: module RNG #(parameter size=8)(output [7:0]SO,output [7:0] RN,input clk,rst,input[size-1:0]seed,input L);    wire [7:0] Sin=SO[7]^SO[5]^SO[4]^SO[3];    ffw F1 (SO,clk,rst,Sin);    MUX M1 (Sin,seed,{SO[size-2:0],next},L);    xor X1 (next,SO[6],SO[7]);    assign RN=next;...
Create an object called Circle. Declare the following integer variables for the object Circle, radius, diameter,...
Create an object called Circle. Declare the following integer variables for the object Circle, radius, diameter, and pi is declared as double. Create the following for the Circle object: ● Implicit constructor (default constructor) ● Void method Calculate (double pi, int radius) to calculate the area of the Circle object. The method must include a system.out statement that displays the area value. Use the following formula to calculate area of the circle: Area = pi * (r * r) Your...
The Random class implements a random number generator, which produces sequences of numbers that appear to...
The Random class implements a random number generator, which produces sequences of numbers that appear to be random. To generate random integers, you construct an object of the Random class, and then apply the nextInt method. For example, the call generator.nextInt(6) gives you a random number between 0 and 5. Write a program DieSimulator that uses the Random class to simulate the cast of a die, printing a random number between 1 and 6 every time that the program is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT