using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class WasteSchedul
{
public void start()
{
int choice = -1;
while (choice != 0)
{
WriteMenuText();
choice = int.Parse(Console.ReadLine());
{
if (choice == 1)
Bin1();
else
Bin2();
}
}
}
public void WriteMenuText()
{
Console.WriteLine("\n1 Bin 1");
Console.WriteLine("2 Bin 2 ");
Console.WriteLine("0 Exit the program");
Console.Write("\nYour choice ");
}
private void Bin1()
{
int count = 52;
int p = 0;
const int cols = 3;
string montera = "";
for (int i = 1; i <= count; i += 2)
{
montera += string.Format("{0,10} {1,2}", "Week", i);
p++;
if ((p >= cols) && (p % cols == 0))
{
Console.WriteLine(montera);
montera = "";
}
}
Console.WriteLine(montera);
Console.WriteLine("\nBin number 1 is emptied the following weeks ");
Console.WriteLine("-------------------------------------------------------");
Console.ReadLine();
}
private void Bin2()
{
int count = 52;
int p = 0;
const int cols = 3;
string montera = "";
for (int i = 5; i <= count; i += 6)
{
montera += string.Format("{0,10} {1,2}", "Week", i);
p++;
if ((p >= cols) && (p % cols == 0))
{
Console.WriteLine(montera);
montera = "";
}
}
Console.WriteLine(montera);
Console.WriteLine("\nBin number 2 is emptied the following weeks ");
Console.WriteLine("-------------------------------------------------------");
Console.ReadLine();
}
}
}
I get every thing to work but the program dont exit when i type 0 it comes to 2 i think i need to do a else if or can i do samthing else? and can anyone tell me how i return the menu after i type in 1

New Topic/Question
Reply



MultiQuote





|