title: Change calculator
body: <p>i have a tusk where i have been asked to write a program that calculate change to be given to a customer after a cash transaction, and determines the number of bank notes and coins in each denomination.</p>
  
  <p>the user has to put in the cost of goods and the amount received from the customer. </p>
  
  <p>I must have a class with a method that accepts decimal arguments, Cost and Chashreceived, plus integer arguments for: Hunderds, Fifties, Twenties, Tens, Fives, Twos, Ones, 50c, 10c, 5c, 2c and 1c.</p>
  
  <p>i substract Cost from  and the Cashreceived and calculate the exact number of notes and coins required to be returned as change.</p>
  
  <p>I have tried it but it become problematic when i have to put in the coins.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace ChangeCalculator
  {
  class Program
  {
      static void Main(string[] args)
      {
          clsCash Money = new clsCash();
          clsCash Paid = new clsCash();
          Console.WriteLine("What is the cost of the goods?");
          Money.Cost = Convert.ToDecimal(Console.ReadLine());
          Console.WriteLine("How much was recived?");
          Paid.CashRecieved = Convert.ToDecimal(Console.ReadLine());
          Money.GetChange(Money.Cost, Paid.CashRecieved);
          Console.Read();
      }
  }
  
  class clsCash
  {
  
  
  private decimal cost;
  private decimal cashRecieved;
  public decimal Cost
  {
      get
      {
          return cost;
      }
      set
      {
          cost = value;
      }
  }
  public decimal CashRecieved
  {
      get
      {
          return cashRecieved;
      }
      set
      {
          cashRecieved = value;
      }
  }
  
  
  
  
  public void GetChange(decimal Cost, decimal CashRecieved)
  {
  
      decimal change = CashRecieved - Cost;
      int hundreds = 0;
      int fifty = 0;
      int twenty = 0;
      int ten = 0;
      int five = 0;
      int two = 0;
      int one = 0;
      int centsfifty = 0;
      int centsten = 0;
      int centsfive = 0;
      int centstwo = 0;
      int centsone = 0;
      do
     {
  
      if (change &gt;= 100)
      {
           hundreds = (int)change / 100;
           change = (int)change % 100;
      } //while (change &gt; 0);
      else if (change &gt;= 50)
      {
          fifty = (int)change / 50;
          change = change % 50;
      }
      else if (change &gt;= 20)
      {
          twenty = (int)change / 20;
          change = change % 20;
      }
      else if (change &gt;= 10)
      {
          ten = (int)change / 10;
          change = change % 10;
      }
      else if (change &gt;= 5)
      {
          five = (int)change / 5;
          change = change % 5;
      }
      else if (change &gt;= 2)
      {
          two = (int)change / 2;
          change = change % 2;
      }
  
      else if (change &gt;= 1)
      {
          one = (int)change / 1;
          change = change % 1;
      }
      else if (change &gt; 1)
      {
          decimal fhu = change / 0.5m;
          centsfifty = (int)fhu;
          change = change % 0.5m;
          Console.WriteLine("YOUR CHANGE IS:");
      }
  
      } while (change &gt;= 0);
  
  
      Console.WriteLine("YOUR CHANGE IS:");
      Console.WriteLine("---------------");
      Console.WriteLine("HUNDREDS RANDS \t:  {0}", hundreds);
      Console.WriteLine("FIFTY RANDS \t:  {0}", fifty);
      Console.WriteLine("TWENTY RANDS \t:  {0}", twenty);
      Console.WriteLine("TEN RANDS \t:  {0}", ten);
      Console.WriteLine("FIVE RANDS \t:  {0}", five);
      Console.WriteLine("TWO RANDS \t:  {0}", two);
      Console.WriteLine("ONE RANDS \t:  {0}", one);
      Console.WriteLine("50 CENTS \t:  {0}", centsfifty);
  
  }
  }
  }
  </code></pre>