Advertisement
Guest User

Untitled

a guest
Mar 29th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.37 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3.  
  4. namespace PETA1___Program_Proposal_Bautista_Banayag
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string menu = @"
  11. - 1 View Student Profile
  12. - 2 Add Student
  13. - 3 Modify Record
  14. - 4 View Total Number of Enrolled Students
  15. - 5 View Number of Available Slots
  16. - 6 View Faculty Profile
  17. - 7 Exit
  18. ";
  19.  
  20. string ansMenu,studId;
  21.  
  22. //2.) add student
  23. string name, section, birthday, sex, interest, address, juniorhs, contactno, emerCon,optMenu,modInput;
  24.  
  25. String[,] students = new String[100, 10];
  26.  
  27. students[0, 0] = "3180100";
  28. students[0, 1] = "Kurt Jacob Urquico";
  29. students[0, 2] = "ICT11A";
  30. students[0, 3] = "August 22, 2001";
  31. students[0, 4] = "Male";
  32. students[0, 5] = "None";
  33. students[0, 6] = "Manila";
  34. students[0, 7] = "Lakandula High School";
  35. students[0, 8] = "09121234567";
  36. students[0, 9] = "09121234567";
  37.  
  38. students[1, 0] = "3180101";
  39. students[1, 1] = "Kyla";
  40. students[1, 2] = "ICT11A";
  41. students[1, 3] = "August 22, 2001";
  42. students[1, 4] = "Male";
  43. students[1, 5] = "None";
  44. students[1, 6] = "Manila";
  45. students[1, 7] = "Lakandula High School";
  46. students[1, 8] = "09121234567";
  47. students[1, 9] = "09121234567";
  48.  
  49. students[2, 0] = "3180102";
  50. students[2, 1] = "Kyla";
  51. students[2, 2] = "ICT11A";
  52. students[2, 3] = "August 22, 2001";
  53. students[2, 4] = "Male";
  54. students[2, 5] = "None";
  55. students[2, 6] = "Manila";
  56. students[2, 7] = "Lakandula High School";
  57. students[2, 8] = "09121234567";
  58. students[2, 9] = "09121234567";
  59.  
  60. int arraySize = students.GetLength(0); //Amount of Rows
  61. int lastIndex = 0;
  62.  
  63. //Loop until the last array is empty
  64. int i = 0;
  65. while (students[i, 0] != null)
  66. {
  67. lastIndex = i;
  68. i++;
  69. }
  70.  
  71. menu:
  72. Console.Clear();
  73.  
  74.  
  75. Console.WriteLine(menu);
  76. Console.Write("Enter Choice: ");
  77. ansMenu = Console.ReadLine();
  78.  
  79. switch (ansMenu)
  80. {
  81. //View
  82. case "1":
  83. Console.Clear();
  84. Console.WriteLine(menu);
  85. Console.WriteLine("Student Profile");
  86. Console.Write("Enter the Student Id No. : ");
  87. studId = Console.ReadLine();
  88.  
  89. bool matched = false;
  90. int ctr = 0;
  91. do
  92. {//left=row, right=coloumn//
  93. if (students[ctr, 0] == studId)
  94. {
  95. Console.WriteLine("\nID Number: " + students[ctr, 0]);
  96. Console.WriteLine("Name: " + students[ctr, 1]);
  97. Console.WriteLine("Section: " + students[ctr, 2]);
  98. Console.WriteLine("Birthday: " + students[ctr, 3]);
  99. Console.WriteLine("Sex: " + students[ctr, 4]);
  100. Console.WriteLine("Interest: " + students[ctr, 5]);
  101. Console.WriteLine("Address: " + students[ctr, 6]);
  102. Console.WriteLine("Junior High School: " + students[ctr, 7]);
  103. Console.WriteLine("Contact No.: " + students[ctr, 8]);
  104. Console.WriteLine("Emergency Contact: " + students[ctr, 9] + "\n");
  105.  
  106. matched = true;
  107. break;
  108. }
  109. else
  110. {
  111. matched = false;
  112. }
  113.  
  114. ctr++;
  115. } while (ctr < arraySize);
  116.  
  117.  
  118. if (matched == false)
  119. {
  120. Console.WriteLine("ID Number Didn't Exist.");
  121. }
  122. Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
  123. optMenu = Convert.ToString(Console.ReadLine());
  124.  
  125. if (optMenu == "M" || optMenu == "m")
  126. {
  127. goto menu;
  128. }
  129. else
  130. {
  131. Environment.Exit(0);
  132. }
  133.  
  134. break;
  135.  
  136. //Add Student
  137. case "2":
  138. int lastID = Convert.ToInt32(students[lastIndex, 0]);
  139. int genID = lastID + 1;
  140. lastIndex++;
  141.  
  142. Console.WriteLine("ID Number: {0}", genID);
  143. Console.Write("Name: ");
  144. name = Convert.ToString(Console.ReadLine());
  145. Console.Write("Section: ");
  146. section = Convert.ToString(Console.ReadLine());
  147. Console.Write("Birthday: ");
  148. birthday = Convert.ToString(Console.ReadLine());
  149. Console.Write("Sex: ");
  150. sex = Convert.ToString(Console.ReadLine());
  151. Console.Write("Interest: ");
  152. interest = Convert.ToString(Console.ReadLine());
  153. Console.Write("Address: ");
  154. address = Convert.ToString(Console.ReadLine());
  155. Console.Write("Junior High School: ");
  156. juniorhs = Convert.ToString(Console.ReadLine());
  157. Console.Write("Contact Number: ");
  158. contactno = Convert.ToString(Console.ReadLine());
  159. Console.Write
  160. ("Emergency Contact Details: ");
  161. emerCon = Convert.ToString(Console.ReadLine());
  162.  
  163. Console.Clear();
  164. Console.WriteLine("Hello This is your personal informations\n");
  165.  
  166. Console.WriteLine("ID Number: {0} ", genID);
  167. Console.WriteLine("Name: {0}", name);
  168. Console.WriteLine("Section: {0}", section);
  169. Console.WriteLine("Birthday: {0}", birthday);
  170. Console.WriteLine("Sex: {0}", sex);
  171. Console.WriteLine("Interest: {0}", interest);
  172. Console.WriteLine("Adress: {0}", address);
  173. Console.WriteLine("Junior Highschool: {0}", juniorhs);
  174. Console.WriteLine("Contact Number: {0}", contactno);
  175. Console.WriteLine("Emergency Contact Details: {0}", emerCon);
  176.  
  177. students[lastIndex, 0] = Convert.ToString(genID);
  178. students[lastIndex, 1] = name;
  179. students[lastIndex, 2] = section;
  180. students[lastIndex, 3] = birthday;
  181. students[lastIndex, 4] = sex;
  182. students[lastIndex, 5] = interest;
  183. students[lastIndex, 6] = address;
  184. students[lastIndex, 7] = juniorhs;
  185. students[lastIndex, 8] = contactno;
  186. students[lastIndex, 9] = emerCon;
  187.  
  188. Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
  189. optMenu = Convert.ToString(Console.ReadLine());
  190.  
  191. if (optMenu == "M" || optMenu == "m")
  192. {
  193. goto menu;
  194. }
  195. else
  196. {
  197. Environment.Exit(0);
  198. }
  199. break;
  200.  
  201. //Edit
  202. case "3":
  203. Console.Write("Enter student number: ");
  204. modInput = Console.ReadLine();
  205.  
  206. int editctr = 0;
  207. bool editmatch = false;
  208. do
  209. {
  210. if (students[editctr, 0] == modInput)
  211. {
  212. Console.WriteLine("Please select the information that you wish to be change");
  213. Console.WriteLine("1.) Name");
  214. Console.WriteLine("2.) Section");
  215. Console.WriteLine("3.) Birthday");
  216. Console.WriteLine("4.) Sex");
  217. Console.WriteLine("5.) Interest");
  218. Console.WriteLine("6.) Address");
  219. Console.WriteLine("7.) Junior Highschool");
  220. Console.WriteLine("8.) Contact Number");
  221. Console.WriteLine("9.) Emergency Contact Details");
  222.  
  223. string selectMod = Console.ReadLine();
  224.  
  225. switch (selectMod)
  226. {
  227. case "1":
  228. Console.Write("Enter new Name: ");
  229. students[editctr, 1] = Console.ReadLine();
  230. break;
  231.  
  232. case "2":
  233. Console.Write("Enter new Section: ");
  234. students[editctr, 2] = Console.ReadLine();
  235. break;
  236.  
  237. case "3":
  238. Console.Write("Enter new Birthday: ");
  239. students[editctr, 3] = Console.ReadLine();
  240. break;
  241.  
  242. case "4":
  243. Console.Write("Enter new Sex: ");
  244. students[editctr, 4] = Console.ReadLine();
  245. break;
  246.  
  247. case "5":
  248. Console.Write("Enter new Interest: ");
  249. students[editctr, 5] = Console.ReadLine();
  250. break;
  251.  
  252. case "6":
  253. Console.Write("Enter new Address: ");
  254. students[editctr, 6] = Console.ReadLine();
  255. break;
  256.  
  257. case "7":
  258. Console.Write("Enter new Junior High School: ");
  259. students[editctr, 7] = Console.ReadLine();
  260. break;
  261.  
  262. case "8":
  263. Console.Write("Enter new Contact Number: ");
  264. students[editctr, 8] = Console.ReadLine();
  265. break;
  266.  
  267. case "9":
  268. Console.Write("Enter new Emergency Contact No. : ");
  269. students[editctr, 9] = Console.ReadLine();
  270. break;
  271. default:
  272. Console.WriteLine("Invalid Input");
  273. break;
  274. }
  275. editmatch = true;
  276. break;
  277. }
  278. else
  279. {
  280. editmatch = false;
  281. }
  282.  
  283. editctr++;
  284. } while (students[editctr, 0] != null);
  285.  
  286. if (editmatch == false)
  287. {
  288. Console.WriteLine("ID Number Didn't Exist.");
  289. }
  290.  
  291. Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
  292. optMenu = Convert.ToString(Console.ReadLine());
  293.  
  294. if (optMenu == "M" || optMenu == "m")
  295. {
  296. goto menu;
  297. }
  298. else
  299. {
  300. Environment.Exit(0);
  301. }
  302. break;
  303.  
  304. case "4":
  305. Console.WriteLine("Total number of students are: {0}", lastIndex + 1);
  306.  
  307. Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
  308. optMenu = Convert.ToString(Console.ReadLine());
  309.  
  310. if (optMenu == "M" || optMenu == "m")
  311. {
  312. goto menu;
  313. }
  314. else
  315. {
  316. Environment.Exit(0);
  317. }
  318. break;
  319.  
  320. case "5":
  321. Console.WriteLine("Available slots are: {0}", arraySize - lastIndex - 1);
  322.  
  323. Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
  324. optMenu = Convert.ToString(Console.ReadLine());
  325.  
  326. if (optMenu == "M" || optMenu == "m")
  327. {
  328. goto menu;
  329. }
  330. else
  331. {
  332. Environment.Exit(0);
  333. }
  334. break;
  335. }
  336. Console.ReadKey();
  337. }
  338. }
  339. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement