⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tempconverter.java

📁 JSP设计(第三版)一书源代码 JSP设计(第三版)》得到了充分的修订和更新
💻 JAVA
字号:
package com.ora.jsp.util;

/**
 * This class contains a couple of static methods for converting 
 * between Fahrenheit and Celsius. The methods are mapped to
 * el functions in the book examples TLD file.
 *
 * @author Hans Bergsten, Gefion software <hans@gefionsoftware.com>
 * @version 1.0
 */
public class TempConverter {
    /**
     * Main method to test the other methods.
     */
    public static void main (String[] args) throws Exception {
        System.out.println("20 C is " + toFahrenheit(20) + " F");
        System.out.println("68 F is " + toCelsius(68) + " C");
    }
    
    public static double toCelsius(double fahrenheit) {
        return (fahrenheit - 32) * 5 / 9;
    }

    public static double toFahrenheit(double celsius) {
        return celsius * 9 / 5 + 32;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -