Answered step by step
Verified Expert Solution
Question
1 Approved Answer
sample code: using System; namespace RandomArray { public class RandomArrayNoDuplicates { static Random rng = new Random(); /// /// Creates an array with each element
sample code:
using System; namespace RandomArray { public class RandomArrayNoDuplicates { static Random rng = new Random(); ///For this exercise, you are asked to write a method called InitializeArraywithNoDuplicates (), using the provided method header below, which will return a one dimensional y in which every element is a randomly generated integer between 1 and 45 inclusive with no integer value occurring more than once in the array The length of the array is passed as a parameter to the method and you can assume that the parameter value will be less than 45 and greater than zero Use the Random class method int Next int minvalue, int maxValue which returns a random ?????? w ch s great 1 an orequa imnalean arra ess than maxValue. To enable you to test your code, you should create a Main() method that calls the InitializeArraywithNoDuplicates() method several times with different parameters each time to show that the method is correct; similar to the Main() method of the linear search exercise in Week 4. lude a simple DisplayArray() method similar to that in the linear search exercise to output the resultant array, called from Main() Exactly what you do to test the method and display the array is not important or your MS m arks as only your InitialzeArrayN?thNoDuplicates This means it must be public. If you still have difficulties, here are some tips when writing programs for AMS: method will be run. Do not write your program directly into the text box. You should copy and paste the sample code into Visual Studio, write your program there, run it and test it to make sure it works, then paste it into AMS. You only get a limited number of attempts at each AMS exercise, so make sure they count If your code uses Console.ReadKey(); it should be replaced with Console.ReadLine(). ReadKey () will work in Visual Studio but not in AMS. Make sure your code displays exactly what the problem asks you for. If you can, copy and paste the text you need to display into your function to avoid possible transcription errors. If there are any mistakes at all your code will not pass/// Creates an array with each element a unique integer /// between 1 and 45 inclusively. /// /// length of the returned array ///an array of length "size" and each element is /// a unique integer between 1 and 45 inclusive public static int[] InitializeArrayWithNoDuplicates(int size) { } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started