skip to Main Content

JAVA: CONVERT CELSIUS TO FAHRENHEIT

JAVA: CONVERT CELSIUS TO FAHRENHEIT

JAVA: CONVERT CELSIUS TO FAHRENHEIT

Java: Convert Celsius to Fahrenheit

package chapter_2_2_1; import java.util.Scanner; /** * * @author Siavash Bakhshi */ public class Chapter_2_2_1 { /** * @param args the command line arguments */ public static void main(String[] args) { // Add Scanner to read input from user Scanner input = new Scanner(System.in); // text to prompt to user asking to enter a number System.out.print("Enter a number (u00b0C): "); double celsius = input.nextDouble(); // Convertion calculation fahrenheit double fahrenheit = (9.0 / 5) * celsius + 32; // Returns the Converted Result in System.out.println(celsius + "u00b0C = " + fahrenheit + "u00b0F"); } }