Advertisement
Guest User

w/e

a guest
Sep 6th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. using System;
  2. namespace Ass1
  3. {
  4. class Arrays
  5. {
  6. static void Main(string[] args)
  7. {
  8. const int MAX_PEOPLE = 50;
  9.  
  10. string[] people;
  11. people = new string[MAX_PEOPLE];
  12.  
  13. string[] full_name;
  14. full_name = new string[MAX_PEOPLE];
  15.  
  16. string[] adress;
  17. adress = new string[MAX_PEOPLE];
  18.  
  19. string[] street_number;
  20. street_number = new string[MAX_PEOPLE];
  21.  
  22. string[] state;
  23. state = new string[MAX_PEOPLE];
  24.  
  25. string[] phone_number;
  26. phone_number = new string[MAX_PEOPLE];
  27.  
  28. string[] post_code;
  29. post_code = new string[MAX_PEOPLE];
  30.  
  31. float[] hours_worked;
  32. hours_worked = new float[MAX_PEOPLE];
  33.  
  34.  
  35. int current_people = 0;
  36. int total_people = 0;
  37. string tval = "";
  38. int c = 0;
  39. char choise = ' ';
  40.  
  41.  
  42. string vtemp = "";
  43. bool parseAttempt = true;
  44. string response = "";
  45.  
  46.  
  47. //Menu displayed
  48. while (response != "x" && response != "X")
  49. {
  50. Console.WriteLine("---------------What do you want to do ?---------------");
  51. Console.WriteLine("");
  52. Console.WriteLine("Add a person (a).");
  53. Console.WriteLine("Find a person(s).");
  54. Console.WriteLine("Display current person (p).");
  55. Console.WriteLine("Delete current person (d)");
  56. Console.WriteLine("Calculate and display pay slip for current person (c)");
  57. Console.WriteLine("");
  58. Console.WriteLine("Press 'x' to Exit. ");
  59.  
  60. response = Console.ReadLine();
  61.  
  62. switch (response)
  63. {
  64.  
  65. case "a":
  66.  
  67. do
  68. {
  69. if (total_people < MAX_PEOPLE)
  70. {
  71. Console.Write("Enter person's full name >");
  72. tval = Console.ReadLine();
  73. full_name[current_people] = tval;
  74.  
  75. Console.Write("Enter person's Street number >");
  76. tval = Console.ReadLine();
  77. street_number[current_people] = tval;
  78.  
  79. Console.Write("Enter person's Street adress >");
  80. tval = Console.ReadLine();
  81. adress[current_people] = tval;
  82.  
  83. Console.Write("Enter person's State >");
  84. tval = Console.ReadLine();
  85. state[current_people] = tval;
  86.  
  87. Console.Write("Enter person's Post code >");
  88. tval = Console.ReadLine();
  89. post_code[current_people] = tval;
  90.  
  91. Console.Write("Enter person's phone number >");
  92. tval = Console.ReadLine();
  93. phone_number[current_people] = tval;
  94.  
  95. Console.Write("Enter person's worked hours >");
  96. tval = Console.ReadLine();
  97. hours_worked[current_people] = float.Parse(tval);
  98. }
  99. else
  100. Console.WriteLine("Person max {0} reached unable to store any more people", MAX_PEOPLE);
  101.  
  102. //Ask user to continue
  103. Console.Write("Press 's'to continue or 'x' to exit ");
  104. choise = char.Parse(Console.ReadLine());
  105.  
  106. } while (choise == 's');
  107. Console.Write("Enter the person to find >");
  108. tval = Console.ReadLine();
  109. for (c = 0; c < total_people; c++)
  110. {
  111. if (people[c] == tval)
  112. {
  113. current_people = c;
  114. break;
  115. }
  116.  
  117.  
  118. }
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127. }
  128. }
  129. }
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement