Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApp1;
- using System.Text;
- public class Task03
- {
- public void Run()
- {
- Console.InputEncoding = Encoding.Unicode;
- Console.OutputEncoding = Encoding.Unicode;
- Console.WriteLine( "Введите имя:" );
- string userName = Console.ReadLine();
- Console.WriteLine( "Введите возраст:" );
- int userAge = int.Parse( Console.ReadLine() );
- Console.WriteLine( "Введите знак зодиака:" );
- string zodiacName = Console.ReadLine();
- int tenDivider = 10;
- int hundredDivider = 100;
- int remainderOfDivisionBy10 = userAge % tenDivider;
- int remainderOfDivisionBy100 = userAge % hundredDivider;
- int tenDividerThresholdLow = 0;
- int tenDividerThresholdHigh = 4;
- int hundredDividerThresholdLow = 11;
- int hundredDividerThresholdHigh = 14;
- var yearSuffix1 = "лет";
- var yearSuffix2 = "год";
- var yearSuffix3 = "года";
- bool isYearSuffixIsFirst = remainderOfDivisionBy10 == tenDividerThresholdLow ||
- remainderOfDivisionBy10 > tenDividerThresholdHigh ||
- (remainderOfDivisionBy100 >= hundredDividerThresholdLow &&
- remainderOfDivisionBy100 <= hundredDividerThresholdHigh);
- string yearSuffix = isYearSuffixIsFirst
- ? yearSuffix1
- : remainderOfDivisionBy10 == 1
- ? yearSuffix2
- : yearSuffix3;
- Console.WriteLine( $"Вас зовут {userName}, вам {userAge} {yearSuffix}, вы {zodiacName} и работаете на заводе." );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement