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

DQuestion 33 1 pts which C# statement assigns a random number from 0 to a number

ID: 3913618 • Letter: D

Question

DQuestion 33 1 pts which C# statement assigns a random number from 0 to a number less than 1 and assigns it to variable taxesTooHigh? Assume rand is a random number generator. taxesTooHigh-rand.Next(); taxesTooHigh NextDouble0: O taxesTooHigh -rand: O taxesTooHigh - rand. NextDouble0 D Question 34 1 pts Which C# statement assigns a random number from 1 through 10 and assigns it to variable rate? Assume rand is a random number generator O rate-rand,Next(10) + 1; O rate-rand.Next(10): O rate Next(10)+ 1; rate rand.Next(10)+10;

Explanation / Answer

Ques 33. Answer : (d) taxes.NextDouble()

-------------------------Sample Code -------------------------

using System;

namespace Rextester

{

    public class Program

    {

        public static void Main(string[] args)

        {

            // create a Random class object

            Random rand = new Random();

           

               

            double taxesTooHigh = rand.NextDouble();

           

            Console.WriteLine(taxesTooHigh);

        }

    }

}

Ques 34. Asnwer : (a) rate = rand.Next(10) + 1

------------------------Sample Code ---------------------

using System;

namespace Rextester

{

    public class Program

    {

        public static void Main(string[] args)

        {

            // create a Random class object

            Random rand = new Random();

           

            // generate random number in range 1 to 10

            // Next(x) returns a random number less than x

            double rate = rand.Next(10) + 1;

           

            Console.WriteLine(rate);

        }

    }

}

Ques 35. Answer : (b) rand.Next(1 , 6)

using System;

namespace Rextester

{

    public class Program

    {

        public static void Main(string[] args)

        {

            // create a Random class object

            Random rand = new Random();

           

            // generate random number in range 1 to 6

            // Next(min, max) returns a random number between (min , max)

            double rate = rand.Next(1 , 6);

           

            Console.WriteLine(rate);

        }

    }

}