need help with void method

I need help with developing an output menu of the retail items below. I would like it to include a part where if you type zero, it will include all items, or if you hit 99, it will exit the menu. It should also include a way to prompt the user to make a selection. Any ideas?

classProgram

{

staticvoid Main(string[] args)

{

//Gum Retail Item

string ItemName;

decimal ItemCost;

decimal ItemPrice;

string Category;

string ItemCode;

decimal ItemWeight;

//figure out the values

ItemName ="Gum";

ItemCost = 0.32m;

ItemPrice = 0.50m;

ItemWeight = 2.0m;

Category ="Candy";

ItemCode ="345A";

//Snickers Retail Item

string ItemName1;

decimal ItemCost1;

decimal ItemPrice1;

string Category1;

string ItemCode1;

decimal ItemWeight1;

//figure out the values

ItemName1 ="Snickers";

ItemCost1 = 0.62m;

ItemPrice1 = 0.80m;

ItemWeight1 = 3.5m;

Category1 ="Candy";

ItemCode1 ="256A";

//pop retail item

string ItemName2;

decimal ItemCost2;

decimal ItemPrice2;

string Category2;

string ItemCode2;

decimal ItemWeight2;

//figure out the values

ItemName2 ="Pop";

ItemCost2 = 0.90m;

ItemPrice2 = 1.00m;

ItemWeight2 = 8.5m;

Category2 ="Bevrge";

ItemCode2 ="656B";

//cigarrettes Retail Item

string ItemName3;

decimal ItemCost3;

decimal ItemPrice3;

string Category3;

string ItemCode3;

decimal ItemWeight3;

//figure out the values

ItemName3 ="Cigarrettes";

ItemCost3 = 2.50m;

ItemPrice3 = 6.00m;

ItemWeight3 = 4.5m;

Category3 ="Smokes";

ItemCode3 ="989C";

//Chips retail Item

string ItemName4;

decimal ItemCost4;

decimal ItemPrice4;

string Category4;

string ItemCode4;

decimal ItemWeight4;

//figure out the values

ItemName4 ="Chips";

ItemCost4 = .50m;

ItemPrice4 = 0.99m;

ItemWeight4 = 1.5m;

Category4 ="Food";

ItemCode4 ="156A";

Console.WriteLine(ItemName +" " +"$" + ItemCost +" " +"$" + ItemPrice +" " +" " +" " + Category +" " +" " +" " + ItemCode +" " +" " +" " + ItemWeight +"oz" );

Console.WriteLine(ItemName1 +" " +"$" + ItemCost1 +" " +" " +"$" + ItemPrice1 +" " +" " +" " + Category1 +" " +" " +" " + ItemCode1 +" " +" " +" " + ItemWeight1 +"oz");

Console.WriteLine(ItemName2 +" " +"$" + ItemCost2 +" " +"$" + ItemPrice2 +" " +" " +" " +"" + Category2 +" " +" " +"" + ItemCode2 +" " +" " +" " + ItemWeight2 +"oz");

Console.WriteLine(ItemName3 +" " +"$" + ItemCost3 +" " +"$" + ItemPrice3 +" " +" " +" " +"" + Category3 +" " +" " +"" + ItemCode3 +" " +" " +" " + ItemWeight3 +"oz");

Console.WriteLine(ItemName4 +" " +"$" + ItemCost4 +" " +"$" + ItemPrice4 +" " +" " +" " + Category4 +" " +" " +" " + ItemCode4 +" " +" " +" " + ItemWeight4 +"oz");

}

[11807 byte] By [ONEWORKNGRL] at [2007-12-22]
# 1

again as the last time, its all done with a while input and waiting for a user input.

you then simply check what option they entered (Console.ReadLine()) and act upon it.

so

while the input is not 99 (99 = exit)

display menu

take input option

check menu option

act upon menu option

end while

this is just a psuedo - a good place for you to start from.

ahmedilyas at 2007-8-30 > top of Msdn Tech,Visual C#,Visual C# Language...
# 2

here is some rough code, which you will have to modify and not guarenteed to work



//main method
string input = String.Empty;
while (!input.Equals("99"))
{
this.DoDisplayMenu()
input = Console.ReadLine();
if (input.Equals("0"))
{
this.DoDisplayAllItems();
}
else if ..... { ... }
......
}
..
private void DoDisplayMenu()
{
Console.WriteLine("0) Exit");
Console.WriteLine("99) Show All Items");
.....
.....
}
private void SomeMethod { .. }
...

hope this gives you a start

The main method, where you will be looping, is the core part of the application in showing the menu system, waiting for user input and acting upon the input.

ahmedilyas at 2007-8-30 > top of Msdn Tech,Visual C#,Visual C# Language...