Guest User

Untitled

a guest
Dec 16th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. 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
  2. should return an array with the users input numbers
  3.  
  4. 1 method should take an array as a parameter, copy that array and double each element, and return the copy array
  5.  
  6. 1 method should display the original
  7.  
  8. **Write the program without any class scoped variables**
  9.  
  10. 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
  11. can grow the array as the user is entering numbers
  12.  
  13. {`enter code here`
  14. //Declarations
  15. int[] numberlist = new int[11];
  16. double[] doublelist = new double[11];
  17. Array.Copy(numberlist, doublelist, numberlist.Length);
  18. int length = numberlist.GetLength(0);
  19. const int end = 0;
  20. int count = 0;
  21.  
  22. Console.Write(" Enter 10 numbers to convert to double n PRESS 0 TO ENDn ");
  23. Console.Write("____________________________________________________________nn");
  24.  
  25. do
  26. {
  27.  
  28. //get user input
  29. for (int i = 1; i < numberlist.Length; i++)
  30. {
  31. Console.Write("| Enter next number: ");
  32. numberlist[i] = Convert.ToInt32(Console.ReadLine());
  33.  
  34.  
  35. }
  36.  
  37. Console.Write(" Results:n");
  38. Console.Write("n____________________________________________________________nn");
  39. //print array
  40. for (int i = 1; i < numberlist.Length; i++)
  41. {
  42. Console.WriteLine($"Number at index ({i}) = {numberlist[i]} ");
  43.  
  44. }
  45.  
  46. Console.ReadKey();
  47.  
  48.  
  49. } while (count != end);
  50. }
  51. }
  52.  
  53. }
Add Comment
Please, Sign In to add comment