What's new

C# stack HELP po.

Maginaku

Eternal Poster
Joined
Jan 28, 2020
Posts
529
Reaction
158
Points
288
Pa help naman po ayan gawa ko at ayan din po yung instructions paguude naman po
 

Attachments

Oo, or meron site mga programmer doon nagtatanong eh. Di ko tanda kung ano pangalan nung site na yun doon nalang sana mag tanong si ts lalo na puro programmer mga tumatambay doon.
 
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
 
[XX='Stale, c: 657507, m: 520608'][/XX] saan po lods? Pa link naman po. Kaylngan lang talaga ng tulong. Salamat po.
 
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;
}
 
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

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
 
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.
 
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.
 
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.
 
just search the error of course.
gawa ka din ng account sa stackoverflow para pwede ka din dun mag ask.

Pwede ka maglagay palagi ng try and catch exception.

Like this:

C#:
try {

YOU CODE HERE

}catch(Exception ex)
{
    //dito mo makikita yung main error tapos yun yung search mo
 Console.Error.WriteLine(ex.Message);
}
 

Similar threads

Back
Top