Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Exercício
- {
- class Program
- {
- static void Main(string[] args)
- {
- /* 18. Escreva um programa para ler dois valores o primeiro indica o tipo de temperatura (C - Celsius ou F - Fahrenheit) e
- o segundo a temperatura. Faça o cálculo realizando as conversões entre as temperaturas:
- a) Celsius para Fahrenheit: F = (9 / 5) * ºC + 32
- b) Fahrenheit para Celsius: C = (ºF − 32) / 1.8 */
- Console.Write("Escolha a temperatura [C] - Celsius ou [F] - Fahrenheit: ");
- string op = Console.ReadLine();
- Console.Write("Digite a temperatura: ");
- double temp = double.Parse(Console.ReadLine());
- if (op == "F")
- {
- double fah = (9 / 5) * temp + 32;
- Console.WriteLine("Temperatura: " + fah.ToString("F2") + "ºF");
- }
- else if (op == "C")
- {
- double cel = (temp - 32) / 1.8;
- Console.WriteLine("Temperatura: " + cel.ToString("F2") + "ºC");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment