fork download
  1. using System;
  2.  
  3. class KiemTraTuoi
  4. {
  5. static void Main()
  6. {
  7. Console.Write("Nhập tuổi của bạn: ");
  8. string input = Console.ReadLine();
  9.  
  10. int tuoi;
  11.  
  12. // Thử chuyển chuỗi nhập vào thành số nguyên
  13. if (int.TryParse(input, out tuoi))
  14. {
  15. if (tuoi < 0)
  16. {
  17. Console.WriteLine("Tuổi không hợp lệ.");
  18. }
  19. else if (tuoi < 18)
  20. {
  21. Console.WriteLine("Bạn là: Vị thành niên.");
  22. }
  23. else if (tuoi < 60)
  24. {
  25. Console.WriteLine("Bạn là: Người trưởng thành.");
  26. }
  27. else
  28. {
  29. Console.WriteLine("Bạn là: Người cao tuổi.");
  30. }
  31. }
  32. else
  33. {
  34. Console.WriteLine("Vui lòng nhập một số nguyên hợp lệ.");
  35. }
  36. }
  37. }
Success #stdin #stdout 0.02s 26268KB
stdin
15
stdout
Nhập tuổi của bạn: Bạn là: Vị thành niên.