Monday, September 10, 2012

Write C# method for ATM money disposal, which take integers in multiple of 100’s as a input and print number denomination (1000’s, 500’s and 100’s) in it.


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y, z, c = 0;
            Console.WriteLine("enter the number");
            x = int.Parse(Console.ReadLine());
            {
                y = x / 1000;
                z = (x % 1000) / 500;
                c = ((x % 1000) % 500) / 100;
            }
            Console.WriteLine("the 1000 is {0}", y);
            Console.WriteLine("the 500 is:" + z);
            Console.WriteLine("the 100 is {0}", c);
            Console.ReadKey();
        }
    }
}

No comments:

Post a Comment