Как сделать программу без цикла while - C#
Формулировка задачи:
Подскажите как сделать программу без цикла вайил
просто ветвлением
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
byte x;
do
Console.WriteLine("Введите число в диапазоне от 0 до 99");
while (!byte.TryParse(Console.ReadLine(), out x) && x < 100);
Console.WriteLine("Сумма {0} {1}", x, GetKop(x));
Console.ReadKey();
}
static string GetKop(int i)
{
if (i < 11 || i > 14)
{
int mod = i % 10;
if (mod == 1)
return "копейка";
if (mod < 5 && mod != 0)
return "копейки";
}
return "копеек";
}
}
}Решение задачи: «Как сделать программу без цикла while»
textual
Листинг программы
if (!byte.TryParse(Console.ReadLine(), out x) || x >=100)
{
Console.WriteLine("Кривой ввод.");
return;
}