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 : 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 where the is the starting number and is the number of multiples, would result in
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 : 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 and an amount is then the list after the function runs should be If the data is and an amount is then the list after the function runs should be The value of amount will be in the range of 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
Your solution alternatively could use a technique called list slicing. While you can use the syntax array for arrays, List in C# uses methods that include the word Range to get the slice. For example, if you had a list data then data.GetRange will give you a new list which goes from the beginning of the list index up for values. If you wrote the slice as data.GetRange data.Count then you would get the list which is index to the end.
Other methods you might find helpful are:
GetRangeindex count
RemoveRangeindex count
AddRangelist or array
InsertRangeindex list or array
Addvalue
Insertindex value
RemoveAtindex
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
