Advertisement
sergezhu

Untitled

Mar 30th, 2023
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. namespace ConsoleApp1;
  2.  
  3. using System.Text;
  4.  
  5. public class Task03
  6. {
  7.     public void Run()
  8.     {
  9.         Console.InputEncoding = Encoding.Unicode;
  10.         Console.OutputEncoding = Encoding.Unicode;
  11.        
  12.         Console.WriteLine( "Введите имя:" );
  13.         string userName = Console.ReadLine();
  14.        
  15.         Console.WriteLine( "Введите возраст:" );
  16.         int userAge = int.Parse( Console.ReadLine() );
  17.        
  18.         Console.WriteLine( "Введите знак зодиака:" );
  19.         string zodiacName = Console.ReadLine();
  20.  
  21.         int tenDivider = 10;
  22.         int hundredDivider = 100;
  23.         int remainderOfDivisionBy10 = userAge % tenDivider;
  24.         int remainderOfDivisionBy100 = userAge % hundredDivider;
  25.  
  26.         int tenDividerThresholdLow = 0;
  27.         int tenDividerThresholdHigh = 4;
  28.         int hundredDividerThresholdLow = 11;
  29.         int hundredDividerThresholdHigh = 14;
  30.  
  31.         var yearSuffix1 = "лет";
  32.         var yearSuffix2 = "год";
  33.         var yearSuffix3 = "года";
  34.  
  35.         bool isYearSuffixIsFirst = remainderOfDivisionBy10 == tenDividerThresholdLow ||
  36.                                    remainderOfDivisionBy10 > tenDividerThresholdHigh ||
  37.                                    (remainderOfDivisionBy100 >= hundredDividerThresholdLow &&
  38.                                     remainderOfDivisionBy100 <= hundredDividerThresholdHigh);
  39.  
  40.         string yearSuffix = isYearSuffixIsFirst
  41.             ? yearSuffix1
  42.             : remainderOfDivisionBy10 == 1
  43.                 ? yearSuffix2
  44.                 : yearSuffix3;
  45.        
  46.         Console.WriteLine( $"Вас зовут {userName}, вам {userAge} {yearSuffix}, вы {zodiacName} и работаете на заводе." );
  47.     }
  48. }
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement