Skip to content

Instantly share code, notes, and snippets.

@jpolivra
Created October 18, 2023 22:28
Show Gist options
  • Save jpolivra/8c749dfb0a9075c22e3c4d7cf56a873c to your computer and use it in GitHub Desktop.
Save jpolivra/8c749dfb0a9075c22e3c4d7cf56a873c to your computer and use it in GitHub Desktop.
Build a table that contains employee name and phone number. Provide a way so it should to possible to search for the employee.
namespace abstract_data_types;
class Program
{
static void Main(string[] args)
{
string[,] EmployeesTable = new string[5, 2];
int i = 0;
while(i < 5)
{
Console.Write($"Insert employee name: ");
EmployeesTable[i, 0] = Console.ReadLine();
Console.Write($"Insert employee phone number: ");
EmployeesTable[i, 1] = Console.ReadLine();
Console.Write($"Employee added successfully!");
Console.WriteLine();
i++;
}
Console.Write("Search for specif employee? (input employee name)");
string SearchValue = Console.ReadLine();
int j = 0;
if(SearchValue.Length == 0) {
j = 5;
Console.Write("Ok! Have a good afternoon! =)");
}
while(j < 5) {
if(EmployeesTable[j, 0] == SearchValue)
{
Console.Write($"Employee {EmployeesTable[j, 0]} found! Phone number: {EmployeesTable[j, 1]} ");
}
j++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment