using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp44
{
internal class Program
{
static string GetName()
{
while (true)
{
Console.Write("Введите имя: ");
string name = Console.ReadLine();
bool isValid = true;
foreach (char c in name)
{
if (!char.IsLetter(c))
{
isValid = false;
break;
}
}
if (isValid)
{
return name;
}
Console.WriteLine("Не корректный ввод! Попробуйте снова!");
}
}
static int GetAge(string name)
{
while (true)
{
try
{
Console.Write("Введите возраст: ");
int age = int.Parse(Console.ReadLine());
return age;
}
catch (FormatException)
{
Console.WriteLine(name + ", не корректный ввод! Попробуй снова!");
}
}
}
static void Main(string[] args)
{
string name = GetName();
int age = GetAge(name);
if (age < 18)
{
Console.WriteLine(name + ", вы несовершеннолетний!");
}
else
{
Console.WriteLine("Имя: " + name + ", возраст: " + age);
}
Console.ReadKey();
}
}
}