// i need help with the program below. i have to convert celsius to fahrenheit.
ID: 3836086 • Letter: #
Question
// i need help with the program below. i have to convert celsius to fahrenheit. the it has to be written in java programmingm and the software that im using is dr java.
import java.util.Scanner;
public class TempConvert {
// Your code for celsiusToFahrenheit here
public static void main(String [] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter current temperature in Celsius: ");
double celsius = in.nextDouble();
System.out.println(celsius + " Celsius is " + celsiusToFahrenheit(celsius) + " in Fahrenheit");
}
}
Explanation / Answer
import java.util.Scanner;
public class TempConvert {
// Your code for celsiusToFahrenheit here
public static double celsiusToFahrenheit(double celsius)
{
return (celsius * 9.0/5) + 32;
}
public static void main(String [] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter current temperature in Celsius: ");
double celsius = in.nextDouble();
System.out.println(celsius + " Celsius is " + celsiusToFahrenheit(celsius) + " in Fahrenheit");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.