mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2025-12-06 05:32:03 +01:00
16 lines
404 B
C#
16 lines
404 B
C#
|
|
using Packt.Shared; // ToWords extension method
|
|||
|
|
using System.Numerics; // BigInteger
|
|||
|
|
|
|||
|
|
Write("Enter a number up to twenty one digits long: ");
|
|||
|
|
string? input = ReadLine();
|
|||
|
|
if (input is null) return;
|
|||
|
|
|
|||
|
|
if (input.Length > 21)
|
|||
|
|
{
|
|||
|
|
WriteLine("I cannot handle more than twenty one digits!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BigInteger number = BigInteger.Parse(input);
|
|||
|
|
|
|||
|
|
WriteLine($"{number:N0} in words is {number.ToWords()}.");
|