Skip to content

Commit

Permalink
cmon tiger u can't let people struggle with numbers like that
Browse files Browse the repository at this point in the history
  • Loading branch information
XTigerHyperX committed Sep 4, 2021
1 parent 74dbeaa commit 93ce4b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
24 changes: 24 additions & 0 deletions Corona Virus Cases 2/Manager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Globalization;

namespace Corona_Virus_Cases_2
{
public static class Manager
{
public static string FormatValue(this decimal num)
{
if (num > 999999 || num < -999999 )
{
return num.ToString("0,,.##M", CultureInfo.InvariantCulture);
}
else
if (num > 999 || num < -999)
{
return num.ToString("0,.#K", CultureInfo.InvariantCulture);
}
else
{
return num.ToString(CultureInfo.InvariantCulture);
}
}
}
}
22 changes: 11 additions & 11 deletions Corona Virus Cases 2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,37 @@ static void Main(string[] args)
foreach (dynamic itemData in data)
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("Cases: " + itemData.cases);
Console.WriteLine("Cases: " +((decimal)itemData.cases).FormatValue());

Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Cases Today : " + itemData.todayCases);
Console.WriteLine("Cases Today : " +((decimal)itemData.todayCases).FormatValue());

Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Active Cases: " + itemData.active);
Console.WriteLine("Active Cases: " + ((decimal)itemData.active).FormatValue());

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nDeaths : " + itemData.deaths);
Console.WriteLine("\nDeaths : " + ((decimal)itemData.deaths).FormatValue());

Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Deaths Today :" + itemData.todayDeaths);
Console.WriteLine("Deaths Today :" + ((decimal)itemData.todayDeaths).FormatValue());

Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine("Critical : " + itemData.critical);
Console.WriteLine("Critical : " + ((decimal)itemData.critical).FormatValue());

Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\nRecovered : " + itemData.recovered);
Console.WriteLine("\nRecovered : " + ((decimal)itemData.recovered).FormatValue());

Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Total Tests : " + itemData.totalTests);
Console.WriteLine("Total Tests : " + ((decimal)itemData.totalTests).FormatValue());

Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.WriteLine("\nCases Per One Million : " + itemData.casesPerOneMillion);
Console.WriteLine("\nCases Per One Million : " + ((decimal)itemData.casesPerOneMillion).FormatValue());

Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Deaths Per One Million : " + itemData.deathsPerOneMillion);
Console.WriteLine("Deaths Per One Million : " + ((decimal)itemData.deathsPerOneMillion).FormatValue());

Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Tests Per One Million : " + itemData.testsPerOneMillion);
Console.WriteLine("Tests Per One Million : " + ((decimal)itemData.testsPerOneMillion).FormatValue() + "\n");

}

Expand Down

0 comments on commit 93ce4b7

Please sign in to comment.