title: c# switch loop, adding up total for each case
body: <p>I have 2 codes that I want to combine into 1 and am having a lot of trouble doing it. The code should ask for the group number then their donation amount and loop back until they press 0. Once they press 0 it should show the total for all groups. Here are the 2 different codes</p>
  
  <p>code 1</p>
  
  <pre><code>using System;
  public class TotalPurchase
  {
      public static void Main()
      {
          double donation;
          double total = 0;
          string inputString;
          const double QUIT = 0;
          Console.WriteLine("Please enter the amount of the contribution: ");
          inputString = Console.ReadLine();
          donation = Convert.ToDouble(inputString);
          while(donation != QUIT)
          {
              total += donation;
              Console.WriteLine("Enter next donation amount, or " +
                  QUIT + " to quit ");
              inputString = Console.ReadLine();
              donation = Convert.ToDouble(inputString);
          }
          Console.WriteLine("Your total is {0}", total.ToString("C"));
      }
  }
  </code></pre>
  
  <p>code 2</p>
  
  <pre><code>using System;
  namespace donate
  {
  
  class donate
  {
      public static void Main()
      {
  
  
          begin:
          string group;
          int myint;
          Console.WriteLine("Please enter group number (4, 5, or 6)");
          Console.WriteLine("(0 to quit): ");
          group = Console.ReadLine();
          myint = Int32.Parse(group);
  
              switch (myint)
              {
                  case 0:
                      Console.WriteLine("Bye.");
                      break;
                  case 4:
                  case 5:
                  case 6:
                       double donation;
  
                       string inputString;
  
                      Console.WriteLine("Please enter the amount of the contribution: ");
                      inputString = Console.ReadLine();
                      donation = Convert.ToDouble(inputString);
                      goto begin;
                  default:
                      Console.WriteLine("Incorrect grade number.", myint);
                      goto begin;
                  }
  
  
  
  
          }       
      }
  }
  </code></pre>
  
  <p>So basically I want to find the total for each group using the 2nd code.</p>
  
  <p>Any help would be greatly appreciated.</p>