using System.Threading.Tasks;
Console.WriteLine("Digite o valor em dólares: ");
if (double.TryParse(Console.ReadLine(), out double valorDolar))
string url = "https://economia.awesomeapi.com.br/json/last/USD-BRL";
using (HttpClient client = new HttpClient())
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
dynamic cotacao = JsonConvert.DeserializeObject(responseBody);
double cotacaoDolar = (double)cotacao.USDBRL.bid;
double valorReal = valorDolar * cotacaoDolar;
Console.WriteLine($"O valor em reais é: R$ {valorReal:F2}");
Console.WriteLine("Valor inválido.");