Java Code Example: convert celsius to fahrenheit

This Java program converts Celsius to Fahrenheit. First, the user is asked to enter a temperature in Celsius of type float. After that the value is converted to Fahrenheit.

The formula for the conversion is:
fahrenheit = celsius * 1,8 +32

import java.util.Scanner;

public class ConvertCelsiusToFahrenheit {
  public static void main(String[] args) {
    double c, f;

    Scanner s = new Scanner(;
    System.out.print("Please enter temperature in celsius: ");

    c = s.nextDouble();
    f = c * 1.8 + 32;


    System.out.print("Temperature in fahrenheit: " + f);
Please enter temperature in celsius: 10
Temperature in fahrenheit: 50.0