Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

sample code: using System; namespace RandomArray { public class RandomArrayNoDuplicates { static Random rng = new Random(); /// /// Creates an array with each element

image text in transcribed

sample code:

using System; namespace RandomArray { public class RandomArrayNoDuplicates { static Random rng = new Random(); ///  /// 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) { } } }
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago