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...
A random number generator picks a number from 7 to 68 in a uniform manner. Round...
A random number generator picks a number from 7 to 68 in a uniform manner. Round answers to 4 decimal places when possible. The mean of this distribution is The standard deviation is The probability that the number will be exactly 42 is P(x = 42) = The probability that the number will be between 16 and 28 is P(16 < x < 28) = The probability that the number will be larger than 48 is P(x > 48) =...
1.) Using excel. A random number generator picks a number from one to nine in a...
1.) Using excel. A random number generator picks a number from one to nine in a uniform manner. X ~ _________ Graph the probability distribution. f(x) = _________ μ = _________ σ = _________ P(3.5 < x < 7.25) = _________ P(x > 5.67) P(x > 5|x > 3) = _________ Find the 90th percentile. 2) using excel A subway train on the Red Line arrives every eight minutes during rush hour. We are interested in the length of time...
A random number generator picks a number from 18 to 64 in a uniform manner. Round...
A random number generator picks a number from 18 to 64 in a uniform manner. Round answers to 4 decimal places when possible. The mean of the distribution is: The standard deviation is: The probability that the number will be exactly 20 is P(x = 20) = The probability that the number will be between 24 and 26 is P(24 < x < 26) = The probability that the number will be larger than 32 is P(x > 32) =...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT