Console.Write("Nhập số thứ nhất: ");
while (!double.TryParse(Console.ReadLine(), out num1))
Console.Write("Giá trị không hợp lệ. Nhập lại số thứ nhất: ");
Console.Write("Nhập số thứ hai: ");
while (!double.TryParse(Console.ReadLine(), out num2))
Console.Write("Giá trị không hợp lệ. Nhập lại số thứ hai: ");
Console.WriteLine("\nMenu:");
Console.WriteLine("1. Thực hiện phép +");
Console.WriteLine("2. Thực hiện phép -");
Console.WriteLine("3. Thực hiện phép *");
Console.WriteLine("4. Thực hiện phép /");
Console.WriteLine("5. Thoát chương trình");
Console.Write("Chọn một tùy chọn (1-5): ");
while (!int.TryParse(Console.ReadLine(), out choice) || choice < 1 || choice > 5)
Console.Write("Lựa chọn không hợp lệ. Vui lòng chọn lại (1-5): ");
Console.WriteLine($"\nKết quả: {num1} + {num2} = {num1 + num2}");
Console.WriteLine($"\nKết quả: {num1} - {num2} = {num1 - num2}");
Console.WriteLine($"\nKết quả: {num1} * {num2} = {num1 * num2}");
Console.WriteLine($"\nKết quả: {num1} / {num2} = {num1 / num2}");
Console.WriteLine("\nLỗi: Không thể chia cho 0!");
Console.Write("Bạn có chắc muốn thoát? (y/n): ");
string exitChoice = Console.ReadLine()?.ToLower();
Console.WriteLine("Chương trình kết thúc.");
Console.WriteLine("Quay lại menu chính...");
Console.Write("\nBạn có muốn quay lại menu chính? (y/n): ");
string continueChoice = Console.ReadLine()?.ToLower();
if (continueChoice == "n")
Console.WriteLine("Chương trình kết thúc.");