Advertisement
sergezhu

Untitled

Mar 30th, 2023
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 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.         bool isYearSuffixEqualsLet = remainderOfDivisionBy10 == tenDividerThresholdLow || remainderOfDivisionBy10 > tenDividerThresholdHigh ||
  32.                                  (remainderOfDivisionBy100 >= hundredDividerThresholdLow && remainderOfDivisionBy100 <= hundredDividerThresholdHigh);
  33.        
  34.         string yearSign = isYearSuffixEqualsLet
  35.             ? "лет"
  36.             : remainderOfDivisionBy10 == 1
  37.                 ? "год"
  38.                 : "годa";
  39.        
  40.         Console.WriteLine( $"Вас зовут {userName}, вам {userAge} {yearSign}, вы {zodiacName} и работаете на заводе." );
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement