What's new

Solved. Salamat po

[XX='Maginaku, c: 657076, m: 1658345'][/XX] sensya ka na lods ha wala akong ide kasi ng c# kaya diko macheck kung saan mga errors nya. i base mo nalang yang output nyang error tas tignan mo yung mga line kung saan sya palyado
 
[XX='ZXCHkr, c: 657092, m: 1270717'][/XX] You do not have permission to view the full content of this post. Log in or register now.

Ayan po online compiler. Try nyo po dito láρág kopo yung code ko pa check po.
 
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);
 
ZXCHkr eto po code ko

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>();

//Add an element
queue.Enqueue("Mama");
queue.Enqueue("Papa");
queue.Enqueue("ate");
queue.Enqueue("Kuya");
queue.Enqueue("Bunso");

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: ");
string add = 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 (add)
{
case 1:
Console.WriteLine("Enter an item to add to Queue:");
string aa = Console.ReadLine();
queue.Enqueue(aa);
break;

case 2:
queue.Dequeue();
Console.WriteLine("Enter an item you want to remove to Queue");
string bb = Console.ReadLine();
queue.Dequeue(bb); q in queue);
Console.WriteLine(q);
break;

case 3:
Console.WriteLine("Enter an Element that you want to search in Queue");
string cc = Console.ReadLine();
queue.Contains(cc);
break;

case 4:
Console.WriteLine("Display Queue Elements");
break;

case 5:
Console.WriteLine("");
break;

}




}

}
}
}
 
Wolfieee28 eto po code ko pa check po. Salamat.

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>();

//Add an element
queue.Enqueue("Mama");
queue.Enqueue("Papa");
queue.Enqueue("ate");
queue.Enqueue("Kuya");
queue.Enqueue("Bunso");

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: ");
string add = 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 (add)
{
case 1:
Console.WriteLine("Enter an item to add to Queue:");
string aa = Console.ReadLine();
queue.Enqueue(aa);
break;

case 2:
queue.Dequeue();
Console.WriteLine("Enter an item you want to remove to Queue");
string bb = Console.ReadLine();
queue.Dequeue(bb); q in queue);
Console.WriteLine(q);
break;

case 3:
Console.WriteLine("Enter an Element that you want to search in Queue");
string cc = Console.ReadLine();
queue.Contains(cc);
break;

case 4:
Console.WriteLine("Display Queue Elements");
break;

case 5:
Console.WriteLine("");
break;

}




}

}
}
}
 
[XX='Maginaku, c: 657125, m: 1658345'][/XX] try mo muna paganahin yung add lods dun sa case 1 mo. pag kasi gumana na sya madai nalang yung iba.
 
[XX='ZXCHkr, c: 657175, m: 1270717'][/XX] kanina ko papo gianagawan ng paraan hindi kopo talaga mawari.
 
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.
 
Back
Top