What's new
  • Welcome to PHCorner forums. Take a moment to sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

Solved. Salamat po

Maginaku

Established
Joined
Jan 28, 2020
Messages
111
Reaction
7
Pa help naman po nito about stack po pa check at patama naman po ng gawa ko eto po code at yung directions.
 

Attachments

Maginaku

Established
manghingi ka muna ng user input mo lods after mo i-display yung mga pagpipilian. after nun, gawan mo ng switch yung variable na yun gamit "int uInput = ReadLine();" tas lagyan mo ng mga conditions yung cases sa switch mo
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace CSharp_Shell
{

public class Program
{
public static void Main()
{
Queue<string> queue = new Queue<string>();
int input = 0;

Console.WriteLine("=>Queue Menu<=");
Console.WriteLine("1.Add an element(Back)");
Console.WriteLine("2.Remove front element");
Console.WriteLine("3.Search an element");
Console.WriteLine("4.Display Queue Elements");
Console.WriteLine("5.Exit");
Console.WriteLine("Enter Your Choice: ");
input = Convert.ToInt32(Console.ReadKey());

//Queue<string> queue = new Queue<string>();
//Add an element
queue.Enqueue("Mama");
queue.Enqueue("Papa");
queue.Enqueue("ate");
queue.Enqueue("Kuya");
queue.Enqueue("Bunso");

//Console.WriteLine("ENTER YOUR CHOICE: ");
//Console.ReadLine();



//Console.WriteLine();
//Remove first element
//queue.Dequeue();

//search element
string search = "second";
var result = queue.FirstOrDefault(x => x.Contains(search));
Console.WriteLine(result );

//display queue
foreach(var q in queue){
Console.WriteLine(q);

int Queue = 0;
switch (Queue)
{
case 1:
Console.WriteLine("All the Elements"+ queue.Count);
break;
case 2:
queue.Dequeue();
Console.WriteLine("Remove front Elemennt");
break;
case 3:
Console.WriteLine("");
break;
case 4:
Console.WriteLine("");
break;
case 5:
Console.WriteLine("");
break;

}




}

}
}
}
 
M
Maginaku
Salamat po ng marami
 

Maginaku

Established
Ayan po yung code ko. Makalat papo. Nilalagay kolang po yung satingin ko kaylangan ko bago ko ayusin kaya kang nakakalito.
 
Comment

Wolfieee28

Grasshopper
Mauna muna dapat yung user input tapos switch case, ang dapat laman nung queue.Enqueue mo is yung makukuha sa ReadLine kaya no need na maglagay ng Mama, Papa, etc.. kasi dapat habang nagrurun yung program, kapag sinelect si 1, doon palang siya dapat magaadd ng element.

so kunwari,
string input = Console.ReadLine();

queue.Enqueue(input);
 
M
Maginaku
Oo nga po mali pala yung code ko dapat ngapo pag sinelect yung 1 tyaka yungbuser mag lakagay ng elements. Kaya lang hindi kopo alam pahelp naman po.
 

Popular On This Forum

Online statistics

Members online
1,739
Guests online
2,184
Total visitors
3,923

Forum statistics

Threads
1,012,380
Messages
17,357,907
Members
1,485,597
Comments
677,859
Attachments
1,135,785
Profile posts
96,441
Top