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());
                switch (choice)
                {
                    case 1:
                        {
                            Bin1();
                                break;
                        }
                    case 2:
                        {
                            Bin2();
                                break;
                        }
                }
            }
        }

        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 need to het a return in to this. When i type in 1 after it i want the menu to come up but how do i do it? and how do you du so it is \n between your choice and the week?

sorry im so tired maybe that's way i cant see it:P

Recommended Answers

All 2 Replies

Did you delete your Main() method?

I have reformatted the code and removed two lines.
I did not add any functionality or correct anything other than making a Main() and making the methods static and removing the Console.ReadLine() calls that are causing you to need to press enter:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
   class WasteSchedul
   {
      public static void WriteMenuText()
      {
         Console.WriteLine("\n1 Bin 1");
         Console.WriteLine("2 Bin 2 ");
         Console.WriteLine("0 Exit the program");
         Console.Write("\nYour choice ");
      }

      private static 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("-------------------------------------------------------");
      }

      private static 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("-------------------------------------------------------");
      }

      public static void Main(string[] args)
      {
         int choice = -1;

         while (choice != 0)
         {
            WriteMenuText();
            choice = int.Parse(Console.ReadLine());
            switch (choice)
            {
               case 1:
               {
                  Bin1();
                  break;
               }
               case 2:
               {
                  Bin2();
                  break;
               }
            }
         }
      }
   }
}
commented: Good work! +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.