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;
- //------------------------------------------------
- // int decimal_part_int = (int)decimal_part;
- int calc;
- // string check = Convert.ToString(decimal_part_int);
- if (Change_as_text.Length >= 3)
- {
- //------------------------------------------------
- calc = Convert.ToInt32(Convert.ToString(Change_as_text[2])); // get the first digit of the decimal
- 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 (Change_as_text.Length == 4)
- {
- calc = Convert.ToInt32(Convert.ToString(Change_as_text[3])); // get the secodn part of the decimal
- //------------------------------------------------
- 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