JAVA Job 1

A conversion temperature (5 min)

Title Contents:

Write a convert Fahrenheit to Celsius program, the conversion formula is:

°F = (9/5)*°C + 32

Wherein C denotes centigrade temperature, F represents Fahrenheit.

Input program is an integer representing Fahrenheit. Celsius temperature corresponding to the output, is also an integer.

Tips, in order to convert the results of the float to integer, use the following expression:

(int)x;

Where x is to convert the floating-point number.

Note: In addition to the output requirements of the subject, can not output any other content, such as input prompts, when output and so can not be explained. This question is required after the digital conversion, the program can only output this figure, in addition to any content can not be output.


Input formats:

An integer.


Output formats:

An integer.


Sample input:

100


Sample output:

37


Code

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		float F;
		int C;
		F = in.nextFloat();
		C = (int)((F-32)/1.8);
		System.out.println(C);

	}

}

Guess you like

Origin blog.csdn.net/dujiafengv/article/details/89287281