Question: Part 1 : Arrays Open up the following code: Arrays.cs Come up with a plan on how to implement the MultiplesOf function. The function should

Part 1: Arrays
Open up the following code: Arrays.cs
Come up with a plan on how to implement the MultiplesOf function. The function should create and return an array of multiples of a number. The starting number and the number of multiples are provided as inputs to the function. For example, MultiplesOf(3,5), where the 3 is the starting number and 5 is the number of multiples, would result in {3,6,9,12,15}.
Using comments in your program, write down your process for solving this problem by step before you write the code.
Implement the MultiplesOf function. (Make sure to leave your comments in the code, even after you have implemented it.)
Part 2: Solving a Complicated Problem Using a List
Come up with a plan on how to implement the RotateListRight function. This function receives a list of data and an amount to rotate to the right.
For example, if the data is {1,2,3,4,5,6,7,8,9} and an amount is 5 then the list after the function runs should be {5,6,7,8,9,1,2,3,4}. If the data is {1,2,3,4,5,6,7,8,9} and an amount is 3 then the list after the function runs should be {7,8,9,1,2,3,4,5,6}. The value of amount will be in the range of 1 and data.Count, inclusive.
Using comments in your program, write down your process for solving this problem by step before you write the code.
Hint: There are multiple ways to solve this problem. Don't worry about trying to find the most elegant solution this week. Your solution could use modulo (%) to deal with wrapping around the index number back to 0.
Your solution alternatively could use a technique called list slicing. While you can use the syntax array[3..] for arrays, List in C# uses methods that include the word __Range to get the slice. For example, if you had a list data ={1,2,3,4,5} then data.GetRange(0,3) will give you a new list {1,2,3} which goes from the beginning of the list (index 0) up for 3 values. If you wrote the slice as data.GetRange(3, data.Count -3) then you would get the list {4,5} which is index 3 to the end.
Other methods you might find helpful are:
GetRange(index, count)
RemoveRange(index, count)
AddRange(list or array)
InsertRange(index, list or array)
Add(value)
Insert(index, value)
RemoveAt(index)
See the documentation for a C# List to see all the methods available.
Implement the RotateListRight function. (Make sure to leave your comments in the code, even after you have implemented it.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!