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!

C# stack HELP po.

Maginaku

Established
Joined
Jan 28, 2020
Messages
111
Reaction
7
Pa help naman po ayan gawa ko at ayan din po yung instructions paguude naman po
 

Attachments

Yup spamming na ginagawa mo kugn apulit ulit ka sa tanong mo. Fifo lang nman yan kaya mo na yan. mas mahihirapan ka kung di mo maiintindihan yan kasi pahirap ng pahirap yan
 
1 Comment
M
Maginaku
Pa help naman po. Pa guide po. Please. Hirap lang po tlaga sa online class at. Wala pong ka close na matatanungan po. Salamat po. Sana ma help nyoko. Btw first year college po ako. Salamat po
 
yung sa switch statement mo, yung case mo ay int.

Ganito dapat.

C#:
var input = int.Parse(Console.ReadLine());

switch(input){
    case 1:
        break;
    case 2:
        break;
    case 3:
        break;
    case 4:
        break;
    case 5:
        break;
}
 
1 Comment
D
donttouchvon
The easiest way hahaha
 
eto ayusin mo nalang at analyze mo rin

1610295212659.png


C#:
Queue<string> queue = new Queue<string>();
start:
System.Console.WriteLine();
System.Console.WriteLine("===========");
System.Console.WriteLine("Queue Menu:");
System.Console.WriteLine("===========\n");

System.Console.WriteLine("[1] Add an element");
System.Console.WriteLine("[2] Remove front element");
System.Console.WriteLine("[3] Search an element");
System.Console.WriteLine("[4] Display all elements");
System.Console.WriteLine("[5] Exit");
System.Console.WriteLine();
choices:
System.Console.WriteLine();
System.Console.Write("Enter your choice > ");
var input = int.Parse(Console.ReadLine());

System.Console.WriteLine();
switch (input)
{
    case 1:
        System.Console.Write("Enter an item to add to queue > ");
        var item = System.Console.ReadLine();

        foreach (var i in item.Split(','))
        {
            queue.Enqueue(i);
        }

        System.Console.WriteLine($"{item} has been added to queue. Total: {queue.Count}");
        goto choices;
    case 2:
        var deq = queue.Dequeue();
        System.Console.WriteLine($"{deq} has been removed to queue");
        goto choices;
    case 3:
        System.Console.Write("Enter an item to search > ");
        var searchItem = Console.ReadLine();
        var result = queue.FirstOrDefault(x => x.Contains(searchItem));
        System.Console.WriteLine($"Found {result}");
        goto choices;
    case 4:
        System.Console.WriteLine($"Queue Items {queue.Count}:");
        foreach(var q in queue){ System.Console.WriteLine($"{q}");}
        goto choices;
    case 5:
        goto start;
}
 

Attachments

Comment

Maginaku

Established
yung sa switch statement mo, yung case mo ay int.

Ganito dapat.

C#:
var input = int.Parse(Console.ReadLine());

switch(input){
    case 1:
        break;
    case 2:
        break;
    case 3:
        break;
    case 4:
        break;
    case 5:
        break;
}
eto ayusin mo nalang at analyze mo rin

View attachment 1126471

C#:
Queue<string> queue = new Queue<string>();
start:
System.Console.WriteLine();
System.Console.WriteLine("===========");
System.Console.WriteLine("Queue Menu:");
System.Console.WriteLine("===========\n");

System.Console.WriteLine("[1] Add an element");
System.Console.WriteLine("[2] Remove front element");
System.Console.WriteLine("[3] Search an element");
System.Console.WriteLine("[4] Display all elements");
System.Console.WriteLine("[5] Exit");
System.Console.WriteLine();
choices:
System.Console.WriteLine();
System.Console.Write("Enter your choice > ");
var input = int.Parse(Console.ReadLine());

System.Console.WriteLine();
switch (input)
{
    case 1:
        System.Console.Write("Enter an item to add to queue > ");
        var item = System.Console.ReadLine();

        foreach (var i in item.Split(','))
        {
            queue.Enqueue(i);
        }

        System.Console.WriteLine($"{item} has been added to queue. Total: {queue.Count}");
        goto choices;
    case 2:
        var deq = queue.Dequeue();
        System.Console.WriteLine($"{deq} has been removed to queue");
        goto choices;
    case 3:
        System.Console.Write("Enter an item to search > ");
        var searchItem = Console.ReadLine();
        var result = queue.FirstOrDefault(x => x.Contains(searchItem));
        System.Console.WriteLine($"Found {result}");
        goto choices;
    case 4:
        System.Console.WriteLine($"Queue Items {queue.Count}:");
        foreach(var q in queue){ System.Console.WriteLine($"{q}");}
        goto choices;
    case 5:
        goto start;
}
Salamat po ah. God bless po. Maraming salamat po talaga. Aaralin kopo ito. Salamat po
 
Comment
Salamat po ah. God bless po. Maraming salamat po talaga. Aaralin kopo ito. Salamat po

welcome lang. Aral lang ng mabuti. Ako di ako natutuo sa school kundi natuto lang with self learning with the help of google and stackoverlow. Hindi lahat ng question mo masasagot dito kaya need mo rin mag explore via searching.
 
Comment

Maginaku

Established
welcome lang. Aral lang ng mabuti. Ako di ako natutuo sa school kundi natuto lang with self learning with the help of google and stackoverlow. Hindi lahat ng question mo masasagot dito kaya need mo rin mag explore via searching.
Salamat po ng marami. God bless.
 
Comment

Maginaku

Established
welcome lang. Aral lang ng mabuti. Ako di ako natutuo sa school kundi natuto lang with self learning with the help of google and stackoverlow. Hindi lahat ng question mo masasagot dito kaya need mo rin mag explore via searching.
Any advice po pala sapag sesearch sa mga problem kung ano po dapat unang gawin sapag sesearch. Ganun po.
 
M
Maginaku
Noted po. Salamat po.
 

Popular On This Forum

Online statistics

Members online
1,761
Guests online
2,211
Total visitors
3,972

Forum statistics

Threads
1,012,369
Messages
17,357,768
Members
1,485,592
Comments
677,814
Attachments
1,135,761
Profile posts
96,441
Top