Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- namespace PETA1___Program_Proposal_Bautista_Banayag
- {
- class Program
- {
- static void Main(string[] args)
- {
- string menu = @"
- - 1 View Student Profile
- - 2 Add Student
- - 3 Modify Record
- - 4 View Total Number of Enrolled Students
- - 5 View Number of Available Slots
- - 6 View Faculty Profile
- - 7 Exit
- ";
- string ansMenu,studId;
- //2.) add student
- string name, section, birthday, sex, interest, address, juniorhs, contactno, emerCon,optMenu,modInput;
- String[,] students = new String[100, 10];
- students[0, 0] = "3180100";
- students[0, 1] = "Kurt Jacob Urquico";
- students[0, 2] = "ICT11A";
- students[0, 3] = "August 22, 2001";
- students[0, 4] = "Male";
- students[0, 5] = "None";
- students[0, 6] = "Manila";
- students[0, 7] = "Lakandula High School";
- students[0, 8] = "09121234567";
- students[0, 9] = "09121234567";
- students[1, 0] = "3180101";
- students[1, 1] = "Kyla";
- students[1, 2] = "ICT11A";
- students[1, 3] = "August 22, 2001";
- students[1, 4] = "Male";
- students[1, 5] = "None";
- students[1, 6] = "Manila";
- students[1, 7] = "Lakandula High School";
- students[1, 8] = "09121234567";
- students[1, 9] = "09121234567";
- students[2, 0] = "3180102";
- students[2, 1] = "Kyla";
- students[2, 2] = "ICT11A";
- students[2, 3] = "August 22, 2001";
- students[2, 4] = "Male";
- students[2, 5] = "None";
- students[2, 6] = "Manila";
- students[2, 7] = "Lakandula High School";
- students[2, 8] = "09121234567";
- students[2, 9] = "09121234567";
- int arraySize = students.GetLength(0); //Amount of Rows
- int lastIndex = 0;
- //Loop until the last array is empty
- int i = 0;
- while (students[i, 0] != null)
- {
- lastIndex = i;
- i++;
- }
- menu:
- Console.Clear();
- Console.WriteLine(menu);
- Console.Write("Enter Choice: ");
- ansMenu = Console.ReadLine();
- switch (ansMenu)
- {
- //View
- case "1":
- Console.Clear();
- Console.WriteLine(menu);
- Console.WriteLine("Student Profile");
- Console.Write("Enter the Student Id No. : ");
- studId = Console.ReadLine();
- bool matched = false;
- int ctr = 0;
- do
- {//left=row, right=coloumn//
- if (students[ctr, 0] == studId)
- {
- Console.WriteLine("\nID Number: " + students[ctr, 0]);
- Console.WriteLine("Name: " + students[ctr, 1]);
- Console.WriteLine("Section: " + students[ctr, 2]);
- Console.WriteLine("Birthday: " + students[ctr, 3]);
- Console.WriteLine("Sex: " + students[ctr, 4]);
- Console.WriteLine("Interest: " + students[ctr, 5]);
- Console.WriteLine("Address: " + students[ctr, 6]);
- Console.WriteLine("Junior High School: " + students[ctr, 7]);
- Console.WriteLine("Contact No.: " + students[ctr, 8]);
- Console.WriteLine("Emergency Contact: " + students[ctr, 9] + "\n");
- matched = true;
- break;
- }
- else
- {
- matched = false;
- }
- ctr++;
- } while (ctr < arraySize);
- if (matched == false)
- {
- Console.WriteLine("ID Number Didn't Exist.");
- }
- Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
- optMenu = Convert.ToString(Console.ReadLine());
- if (optMenu == "M" || optMenu == "m")
- {
- goto menu;
- }
- else
- {
- Environment.Exit(0);
- }
- break;
- //Add Student
- case "2":
- int lastID = Convert.ToInt32(students[lastIndex, 0]);
- int genID = lastID + 1;
- lastIndex++;
- Console.WriteLine("ID Number: {0}", genID);
- Console.Write("Name: ");
- name = Convert.ToString(Console.ReadLine());
- Console.Write("Section: ");
- section = Convert.ToString(Console.ReadLine());
- Console.Write("Birthday: ");
- birthday = Convert.ToString(Console.ReadLine());
- Console.Write("Sex: ");
- sex = Convert.ToString(Console.ReadLine());
- Console.Write("Interest: ");
- interest = Convert.ToString(Console.ReadLine());
- Console.Write("Address: ");
- address = Convert.ToString(Console.ReadLine());
- Console.Write("Junior High School: ");
- juniorhs = Convert.ToString(Console.ReadLine());
- Console.Write("Contact Number: ");
- contactno = Convert.ToString(Console.ReadLine());
- Console.Write
- ("Emergency Contact Details: ");
- emerCon = Convert.ToString(Console.ReadLine());
- Console.Clear();
- Console.WriteLine("Hello This is your personal informations\n");
- Console.WriteLine("ID Number: {0} ", genID);
- Console.WriteLine("Name: {0}", name);
- Console.WriteLine("Section: {0}", section);
- Console.WriteLine("Birthday: {0}", birthday);
- Console.WriteLine("Sex: {0}", sex);
- Console.WriteLine("Interest: {0}", interest);
- Console.WriteLine("Adress: {0}", address);
- Console.WriteLine("Junior Highschool: {0}", juniorhs);
- Console.WriteLine("Contact Number: {0}", contactno);
- Console.WriteLine("Emergency Contact Details: {0}", emerCon);
- students[lastIndex, 0] = Convert.ToString(genID);
- students[lastIndex, 1] = name;
- students[lastIndex, 2] = section;
- students[lastIndex, 3] = birthday;
- students[lastIndex, 4] = sex;
- students[lastIndex, 5] = interest;
- students[lastIndex, 6] = address;
- students[lastIndex, 7] = juniorhs;
- students[lastIndex, 8] = contactno;
- students[lastIndex, 9] = emerCon;
- Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
- optMenu = Convert.ToString(Console.ReadLine());
- if (optMenu == "M" || optMenu == "m")
- {
- goto menu;
- }
- else
- {
- Environment.Exit(0);
- }
- break;
- //Edit
- case "3":
- Console.Write("Enter student number: ");
- modInput = Console.ReadLine();
- int editctr = 0;
- bool editmatch = false;
- do
- {
- if (students[editctr, 0] == modInput)
- {
- Console.WriteLine("Please select the information that you wish to be change");
- Console.WriteLine("1.) Name");
- Console.WriteLine("2.) Section");
- Console.WriteLine("3.) Birthday");
- Console.WriteLine("4.) Sex");
- Console.WriteLine("5.) Interest");
- Console.WriteLine("6.) Address");
- Console.WriteLine("7.) Junior Highschool");
- Console.WriteLine("8.) Contact Number");
- Console.WriteLine("9.) Emergency Contact Details");
- string selectMod = Console.ReadLine();
- switch (selectMod)
- {
- case "1":
- Console.Write("Enter new Name: ");
- students[editctr, 1] = Console.ReadLine();
- break;
- case "2":
- Console.Write("Enter new Section: ");
- students[editctr, 2] = Console.ReadLine();
- break;
- case "3":
- Console.Write("Enter new Birthday: ");
- students[editctr, 3] = Console.ReadLine();
- break;
- case "4":
- Console.Write("Enter new Sex: ");
- students[editctr, 4] = Console.ReadLine();
- break;
- case "5":
- Console.Write("Enter new Interest: ");
- students[editctr, 5] = Console.ReadLine();
- break;
- case "6":
- Console.Write("Enter new Address: ");
- students[editctr, 6] = Console.ReadLine();
- break;
- case "7":
- Console.Write("Enter new Junior High School: ");
- students[editctr, 7] = Console.ReadLine();
- break;
- case "8":
- Console.Write("Enter new Contact Number: ");
- students[editctr, 8] = Console.ReadLine();
- break;
- case "9":
- Console.Write("Enter new Emergency Contact No. : ");
- students[editctr, 9] = Console.ReadLine();
- break;
- default:
- Console.WriteLine("Invalid Input");
- break;
- }
- editmatch = true;
- break;
- }
- else
- {
- editmatch = false;
- }
- editctr++;
- } while (students[editctr, 0] != null);
- if (editmatch == false)
- {
- Console.WriteLine("ID Number Didn't Exist.");
- }
- Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
- optMenu = Convert.ToString(Console.ReadLine());
- if (optMenu == "M" || optMenu == "m")
- {
- goto menu;
- }
- else
- {
- Environment.Exit(0);
- }
- break;
- case "4":
- Console.WriteLine("Total number of students are: {0}", lastIndex + 1);
- Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
- optMenu = Convert.ToString(Console.ReadLine());
- if (optMenu == "M" || optMenu == "m")
- {
- goto menu;
- }
- else
- {
- Environment.Exit(0);
- }
- break;
- case "5":
- Console.WriteLine("Available slots are: {0}", arraySize - lastIndex - 1);
- Console.WriteLine("Press M to go Back to Menu, Press E to Exit");
- optMenu = Convert.ToString(Console.ReadLine());
- if (optMenu == "M" || optMenu == "m")
- {
- goto menu;
- }
- else
- {
- Environment.Exit(0);
- }
- break;
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement