Answer to Question #300469 in Java | JSP | JSF for Oluwaseun Isaac

Question #300469

2.2

(Convert Celsius to Fahrenheit) Write a program that reads a Celsius degree in

a double value from the console, then converts it to Fahrenheit and displays the

result. The formula for the conversion is as follows:

fahrenheit = (9 / 5) * celsius + 32

Hint: In Java, 9 / 5 is 1, but 9.0 / 5 is 1.8.

Here is a sample run:


Enter a degree in Celsius: 43

43 Celsius is 109.4 Fahrenheit


1
Expert's answer
2022-02-21T01:27:36-0500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter a degree in Celsius: ");
        double celsius = in.nextDouble();
        System.out.println(celsius + " Celsius is " + (9 * celsius / 5 + 32) + " Fahrenheit");
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS