Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
1,690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05._Coins
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             decimal amount = decimal.Parse(Console.ReadLine());
  10.             int coin = 0;
  11.      
  12.                 coin += Convert.ToInt32(Math.Truncate(amount / 2));
  13.                 amount = amount % 2;
  14.                 coin += Convert.ToInt32(Math.Truncate(amount / 1));
  15.                 amount = amount % 1;
  16.                 coin += Convert.ToInt32(Math.Truncate(amount / 0.50m));
  17.                 amount = amount % 0.5m;
  18.                 coin += Convert.ToInt32(Math.Truncate(amount /0.20m));
  19.                 amount = amount % 0.20m;
  20.                 coin += Convert.ToInt32(Math.Truncate(amount / 0.10m));
  21.                 amount = amount % 0.10m;
  22.                 coin += Convert.ToInt32(Math.Truncate(amount / 0.05m));
  23.                 amount = amount % 0.05m;
  24.                 coin += Convert.ToInt32(Math.Truncate(amount / 0.02m));
  25.                 amount = amount % 0.02m;
  26.                 coin += Convert.ToInt32(Math.Truncate(amount / 0.01m));
  27.                 amount = amount % 0.01m;
  28.                 Console.WriteLine(coin);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement