public class TempFahrenheit {
public static void main(String[] args) {
double celsius = 45.1;
double tempFahrenheit;
tempFahrenheit = (celsius * 1.8) + 32;
System.out.println(tempFahrenheit);
int convertFahrenheit = (int) (tempFahrenheit);
System.out.println(convertFahrenheit);
}
}
código completo
public class TempFahrenheit {
public static void main(String[] args) {
double celsius = 45.1;
double tempFahrenheit;
tempFahrenheit = (celsius * 1.8) + 32;
String mensagem = String.format("A temperatura em Celsius é de %.1f, enquanto em Fahrenheit é de %.1f.", celsius, tempFahrenheit);
System.out.println(mensagem);
int convertFahrenheit = (int) (tempFahrenheit);
System.out.println("A temperatura inteira em Fahrenheit é de " + convertFahrenheit + ".");
}
}