Using the formula C = (5/9) (F-32) to print the following Fahrenheit and Celsius temperature table.

Using the formula C = (5/9) (F-32) to print the following Fahrenheit and Celsius temperature table.

0      -17

20     -6

40     4

60     15

80     26

100    37

120    48

140    60

160    71

180    82

200    93

220    104

240    115

260    126

280    137

300    148

Thinking:

Data output include tabs neater;

Let Celsius to one decimal place.

Modify the temperature conversion program, required in reverse order (in order from 0 degrees to 300 degrees) printing temperature conversion table.

 

 

 

 

// This is one decimal place, the biggest difficulty is the num casts

 

import java.util.Scanner;

public class Lesson1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		/*Scanner input=new Scanner(System.in);	
		int f=input.nextInt();*/
	     for(int i=0;i<=300;i+=20){
	    	 double  num=  (((double)5/9)*(i-32));
	    	 String  temp=String.format("%.1f", num);
	    	 System.out.println(i+"	"+temp);
	     }
		
	}

}


 

 

 

 

 

Published 143 original articles · won praise 1 · views 1584

Guess you like

Origin blog.csdn.net/zhupengqq1/article/details/104087296