Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 method should repeatedly ask a user for a number (up to 10 total numbers) or they can stop early by entering 0 This method
- should return an array with the users input numbers
- 1 method should take an array as a parameter, copy that array and double each element, and return the copy array
- 1 method should display the original
- **Write the program without any class scoped variables**
- To make this easier, if the user does not enter all 10 numbers you do not have to keep track of the exact number they entered For more of a challenge you
- can grow the array as the user is entering numbers
- {`enter code here`
- //Declarations
- int[] numberlist = new int[11];
- double[] doublelist = new double[11];
- Array.Copy(numberlist, doublelist, numberlist.Length);
- int length = numberlist.GetLength(0);
- const int end = 0;
- int count = 0;
- Console.Write(" Enter 10 numbers to convert to double n PRESS 0 TO ENDn ");
- Console.Write("____________________________________________________________nn");
- do
- {
- //get user input
- for (int i = 1; i < numberlist.Length; i++)
- {
- Console.Write("| Enter next number: ");
- numberlist[i] = Convert.ToInt32(Console.ReadLine());
- }
- Console.Write(" Results:n");
- Console.Write("n____________________________________________________________nn");
- //print array
- for (int i = 1; i < numberlist.Length; i++)
- {
- Console.WriteLine($"Number at index ({i}) = {numberlist[i]} ");
- }
- Console.ReadKey();
- } while (count != end);
- }
- }
- }
Add Comment
Please, Sign In to add comment