Check Quantity of sum
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace CheckQuantityOfNum
{
public class Program
{
public static void Main()
{
Console.WriteLine("Enter a number");
string number = Console.ReadLine();
Count(number);
}
public static void Count(string number)
{
int one = 0, two = 0, three = 0, four = 0, five = 0, six = 0, seven = 0, eight = 0, nine = 0, zero = 0;
for (int i = 0; i < number.Length; i++)
{
switch (number[i])
{
case '1':
one++;
break;
case '2':
two++;
break;
case '3':
three++;
break;
case '4':
four++;
break;
case '5':
five++;
break;
case '6':
six++;
break;
case '7':
seven++;
break;
case '8':
eight++;
break;
case '9':
nine++;
break;
case '0':
zero++;
break;
}
}
Console.WriteLine("0 = {9}\n1 = {0}\n2 = {1} \n3 = {2}\n4 = {3}\n5 = {4}\n6 = {5}\n7 = {6}\n8 = {7}\n9 = {8}", one, two, three, four, five, six, seven, eight, nine, zero);
}
}
}
Comments
Post a Comment