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);
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.