Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static void AgeAnalys(int age)
- {
- if (age < 0)
- {
- throw new ArgumentException("Negative age...");
- }
- if (age <= 12)
- {
- Console.WriteLine("Kid");
- }
- else if (age <= 19)
- {
- Console.WriteLine("Teen");
- }
- else
- {
- Console.WriteLine("Adult");
- }
- }
- static void Main(string[] args)
- {
- int num = -15;
- try
- {
- AgeAnalys(num);
- }
- catch(ArgumentException)
- {
- Console.WriteLine("Problem...");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement