For full functionality of this site it is necessary to enable JavaScript. Here are the instructions how to enable JavaScript in your web browser.

All for Joomla All for Webmasters
Close

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");
     }
}
Java: Convert Celsius to Fahrenheit (536 downloads)