Advertisement
Dianov

Basic Syntax, Conditional Statements and Loops - Exercise (01. Ages)

Mar 26th, 2021
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Ages
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int age = int.Parse(Console.ReadLine());
  14.  
  15.             if (age >= 0 && age <= 2)
  16.             {
  17.                 Console.WriteLine("baby");
  18.             }
  19.             else if (age >= 3 && age <= 13)
  20.             {
  21.                 Console.WriteLine("child");
  22.             }
  23.             else if (age >= 14 && age <= 19)
  24.             {
  25.                 Console.WriteLine("teenager");
  26.             }
  27.             else if (age >= 20 && age <= 65)
  28.             {
  29.                 Console.WriteLine("adult");
  30.             }
  31.             else if (age >= 66)
  32.             {
  33.                 Console.WriteLine("elder");
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement