Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace coins
- {
- class Program
- {
- static void Main(string[] args)
- { //------------------------------------------------
- string Change_as_text = Console.ReadLine();
- double change = double.Parse(Change_as_text);
- //------------------------------------------------
- int hundreds = 0;
- int tens = 0;
- int ones = 0;
- int twos = 0;
- int twenties = 0;
- int fives = 0;
- int fifties = 0;
- //------------------------------------------------
- double Decimal_Part = change - ((int)change);
- string Decimal_as_Text = Decimal_Part.ToString("F2");
- if (Decimal_as_Text.Length == 3) { Decimal_Part *= 10; }
- if (Decimal_as_Text.Length == 4) { Decimal_Part *= 100; }
- int Decimal_Int = (int)Decimal_Part;
- string Decimal_Final = Convert.ToString(Decimal_Int);
- int calc;
- //Console.WriteLine(Decimal_as_Text);
- if (Decimal_Final.Length >= 1)
- {
- //------------------------------------------------
- calc = Convert.ToInt32(Convert.ToString(Decimal_Final[0])); // get the first digit of the decimal
- // Console.WriteLine(calc);
- if (calc == 1) { tens++; }
- if (calc == 2) { twenties++; }
- if (calc == 3) { twenties++; tens++; }
- if (calc == 4) { twenties += 2; }
- if (calc == 5) { fifties++; }
- if (calc == 6) { fifties++; tens++; }
- if (calc == 7) { fifties++; twenties++; }
- if (calc == 8) { fifties++; twenties++; tens++; }
- if (calc == 9) { fifties++; twenties += 2; ; }
- //------------------------------------------------
- }
- if (Decimal_Final.Length == 2)
- {
- calc = Convert.ToInt32(Convert.ToString(Decimal_Final[1])); // get the secodn part of the decimal
- // Console.WriteLine(calc);
- //------------------------------------------------
- if (calc == 1) { ones++; }
- if (calc == 2) { twos++; }
- if (calc == 3) { twos++; ones++; }
- if (calc == 4) { twos += 2; }
- if (calc == 5) { fives++; }
- if (calc == 6) { fives++; ones++; }
- if (calc == 7) { fives++; twos++; }
- if (calc == 8) { fives++; twos++; ones++; }
- if (calc == 9) { fives++; twos += 2; }
- //------------------------------------------------
- }
- if ((int)change == 1) { hundreds = 1; };
- if ((int)change == 2)
- {
- hundreds = 1;
- };
- if ((int)change > 2)
- {
- if ((int)change % 2 == 0)
- { hundreds = (int)change / 2; }
- else
- { hundreds = ((int)change / 2) + 1; }
- }
- //-------------------------------------
- Console.WriteLine(hundreds + tens + twenties + fifties + twos + ones + fives);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement