1 /** 2 * @author 冰樱梦 3 * 时间:2018年下半年 4 * 题目:摄氏度和华氏度之间的额转换 5 * 6 */ 7 public class Exercise06_08 { 8 public static void main(String[] args){ 9 System.out.printf("%-23s%-22s%-20s%-10s","摄氏度","华氏度","华氏度","摄氏度"); 10 System.out.println(" ————————————————————————————————————————————————"); 11 for(double i=40,j=120;i>=31&&j>=30;i--,j-=10){ 12 System.out.printf("%-10.1f%-10.1f%-10.1f%.1f ",i,celsiusToFahrenheit(i),j,fahrenheitToCelsius(j)); 13 } 14 15 } 16 public static double celsiusToFahrenheit(double celsius){ 17 return (9.0/5)*celsius+32; 18 } 19 public static double fahrenheitToCelsius(double fahrenheit){ 20 return (5.0/9)*(fahrenheit-32); 21 } 22 }