online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
using System; using System.Collections.Generic; using System.Threading; class Program { static string newLine = Environment.NewLine; // name surname static List<Tuple<string, string>> students = new List<Tuple<string, string>>(); static void Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.UTF8; PoweredBy(); FakeLoader(); Menu(); Environment.Exit(0); } static void Menu() { ShowMenuOptions(); while (true) { Console.Write("\rInsert an option number (1-5): "); ConsoleKeyInfo keyInfo = Console.ReadKey(); char keyChar = keyInfo.KeyChar; if (char.IsDigit(keyChar)) { int input = int.Parse(keyChar.ToString()); if (input >= 1 && input <= 6) { switch (input) { case 1: Menu__AddStudent(); break; case 2: Menu__DeleteStudent(); break; case 3: Menu__ShowAllStudents(); break; case 4: Menu__SearchStudent(); break; case 5: Menu__CreateDemoList(); break; case 6: Menu__Exit(); return; } } } } } static void Menu__AddStudent() { PoweredBy(); Console.Write("Enter student's first name: "); string name = Console.ReadLine().Trim(); Console.Write("Enter student's surname: "); string surname = Console.ReadLine().Trim(); if (!String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(surname)) { name = CapitalizeFirstLetter(name); surname = CapitalizeFirstLetter(surname); students.Add(Tuple.Create(name, surname)); Console.Write("Student " + name + " " + surname + " has been added."); } else { Console.Write("Student has not been added due to missing information."); } Thread.Sleep(2500); ShowMenuOptions(); } static void Menu__DeleteStudent() { PoweredBy(); if (students.Count != 0) { Console.Write("Enter student's name to delete: "); string name = Console.ReadLine().Trim(); Console.Write("Enter student's surname to delete: "); string surname = Console.ReadLine().Trim(); name = CapitalizeFirstLetter(name); surname = CapitalizeFirstLetter(surname); var studentToDelete = students.Find(student => student.Item1 == name && student.Item2 == surname); if (studentToDelete != null) { students.Remove(studentToDelete); Console.Write("Student " + name + " " + surname + " has been deleted."); } else { Console.Write("Student not found."); } } else { ErrorText("No students on the list. You cannot delete a student."); } Thread.Sleep(2500); ShowMenuOptions(); } static void Menu__ShowAllStudents() { PoweredBy(); if (students.Count != 0) { TitleLine("List of all students:"); int index = 1; foreach (var student in students) { Console.WriteLine(index++ + ". " + student.Item1 + " " + student.Item2); } Console.Write(newLine + "Press spacebar button to exit to main menu."); Console.ReadKey(); } else { ErrorText("No students on the list. Cannot show all students."); Thread.Sleep(2500); } ShowMenuOptions(); } static void Menu__SearchStudent() { PoweredBy(); if (students.Count != 0) { Console.Write("Enter student's name to search: "); string name = Console.ReadLine().Trim(); Console.Write("Enter student's surname to search: "); string surname = Console.ReadLine().Trim(); name = CapitalizeFirstLetter(name); surname = CapitalizeFirstLetter(surname); var studentFound = students.Find(student => student.Item1 == name && student.Item2 == surname); if (studentFound != null) { Console.Write("Student found: " +studentFound.Item1 + " " +studentFound.Item2); } else { Console.Write("Student not found."); } } else { ErrorText("No students on the list. You cannot search for a student."); } Thread.Sleep(2500); ShowMenuOptions(); } static void Menu__CreateDemoList() { PoweredBy(); List<Tuple<string, string>> demoStudents = new List<Tuple<string, string>>() { Tuple.Create("Ivan", "Ivanov"), Tuple.Create("Maria", "Petrova"), Tuple.Create("Alexei", "Sidorov"), Tuple.Create("Anna", "Kuznetsova"), Tuple.Create("Dmitry", "Popov"), Tuple.Create("Olga", "Volkova"), Tuple.Create("Sergey", "Mikhailov"), Tuple.Create("Ekaterina", "Fedorova"), Tuple.Create("Andrei", "Nikolaev"), Tuple.Create("Yulia", "Smirnova") }; students.AddRange(demoStudents); Console.Write("Demo list of students has been created."); Thread.Sleep(2500); ShowMenuOptions(); } static void Menu__Exit() { PoweredBy(); Console.Write("Bye! Do not forget to send greetings to the DJ and Junior Tours!"); Thread.Sleep(2500); } static void ShowMenuOptions() { PoweredBy(); TitleLine("Choose one of the options"); Console.WriteLine ( "1 - To Enter a student" + newLine + "2 - To Delete Student" + newLine + "3 - To Show All Students" + newLine + "4 - To Search a Student" + newLine + "5 - Create Demo list of students" + newLine + "6 - To Exit" + newLine ); } static string CapitalizeFirstLetter(string text) { if (!String.IsNullOrEmpty(text)) return char.ToUpper(text[0]) + text.Substring(1).ToLower(); return text; } static void ErrorText(string text) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(text); Console.ForegroundColor = ConsoleColor.White; } static void TitleLine(string text) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine(" " + text + " "); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; } static void PoweredBy() { string coder = "Powered by DJ KrassiBoy"; string welcome = "Welcome to the student management program of 11th A GRADE"; string border = new string('*', welcome.Length + 4); Console.Clear(); Console.WriteLine ( border + newLine + "* " + coder.PadRight(border.Length - 3) + "*" + newLine + "* " + welcome.PadRight(border.Length - 3) + "*" + newLine + border + newLine ); } static void FakeLoader(string text = "Loading") { string loadingText = text; int dotCount = 3; // Number of dots in the animation Random random = new Random(); // Random number generator int cycles = random.Next(3, 6); // Random number of animation cycles between 3 and 6 string clearLine = new string(' ', loadingText.Length + dotCount); // Clear line for erasing content for (int j = 0; j < cycles; j++) // Loop for the number of animation cycles { for (int i = 0; i <= dotCount; i++) // Loop through each animation step { Console.Write("\r" + clearLine); // Clear the current line Console.Write("\r" + loadingText + new string('.', i)); // Display the loading text with dots Thread.Sleep(500); // Wait for the next frame - delay between frames in milliseconds } } Console.Write("\r" + clearLine + "\n"); } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue