0% found this document useful (0 votes)
8 views2 pages

Edp

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Edp

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections;

namespace ConsoleApp1
{
class Program
{
//Declaration of Queue
static Queue items = new Queue();
static void Main()
{

int option = 0; //This will handle the option number


bool loop = true; //This will continue the loop. To terminate, asign
false to loop variable

while (loop == true)


{
Console.WriteLine("Choose one option: \n1) Add a Name \n2) Remove a
Name \n3) Peek a Name \n4) Show all Names \n5) Exit\n");

//This will accept the user input


Console.Write("Enter option number: ");
option = Int32.Parse(Console.ReadLine());

//This will determine what method to call


if (option == 1)
{
addItem();
}
else if (option == 2)
{
removeItem();
}
else if (option == 3)
{
peekItem();
}
else if (option == 4)
{
showItems();
}
else
{
//This will terminate the loop.
loop = false;
Console.WriteLine("Program Terminated");
}
Console.Write("-------------------------------------\n");
}
}
public static void addItem()
{
Console.WriteLine("Option 1");
items.Enqueue("Wendell");
items.Enqueue("Allen");
items.Enqueue("Belando");
foreach (var x in items)
{
Console.WriteLine(x);
}

}
public static void removeItem()
{
Console.WriteLine("Option 2");
items.Dequeue();
foreach (var x in items)
{
Console.WriteLine(x);
}

}
public static void peekItem()
{
Console.WriteLine("Option 3");
Console.WriteLine(items.Peek());
}
public static void showItems()
{
Console.WriteLine("Option 4");
foreach (var x in items)
{
Console.WriteLine(x);
}
}
}
}

You might also like