1
resposta

[Projeto] Conversor de Temperatura ( °C to F)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner entrada = new Scanner(System.in);
        double temperaturaEmCelsius;
        System.out.println("Vamos converter as temperaturas de Celsius para Farenheit\n1º Informe a temperatura em Celsius: ");
        temperaturaEmCelsius = entrada.nextDouble(); //interação com usuário
        double temperaturaEmFahrenheit = (temperaturaEmCelsius * 1.8) + 32;

        int temperaturaEmFahrenheintinteira = (int) temperaturaEmFahrenheit;
        System.out.println("A temperatura em Fahhrenheit é: " + temperaturaEmFahrenheintinteira);

    }
}

Matricule-se agora e aproveite até 50% OFF

O maior desconto do ano para você evoluir com a maior escola de tecnologia

QUERO APROVEITAR
1 resposta

Interessante usar o Scanner para deixar aberto ao usuário converter qualquer valor de temperatura!