java doc书写_Javadoc 注释书写规范

package com.datastructure.one;

/**

*The TemperatureConversion Java applicatoin prints a table

*converting Celsius to Fahrenheit degress.

* @author zhangzhaoyu

* zhangzhaoyu@163.com

*/

public class TemperatureConversion {

public static void main(String[] args) {

final double TABLE_BEGIN = -50.0;

final double TABLE_END = 50.0;

final double TABLE_STEP = 10.0;

double celsius;

double fahrenheit;

System.out.println("TEMPERATURE CONVERSION");

System.out.println("----------------------");

System.out.println("Celsius Fahrenheit");

for (celsius = TABLE_BEGIN; celsius < TABLE_END; celsius += TABLE_STEP ) {

fahrenheit = celsiusToFahrenheit(celsius);

System.out.printf("%6.2fC", celsius);

System.out.printf("%1.4fF\n", fahrenheit);

}

System.out.println("----------------------");

}

/**

* Convert a temperature from Celius to Fahrenheit.

* @param c

* a temperature in Celsius degress

* @precondition

* c >= -273.15

* @return

* the temperature c converted to Fahrenheit

* @postcondition

* The Fahrenheit temperature equivalent to c has been

* printed to System.out

* @throws IllegalArgumentException

* Indicates that c is less than the smallest Celsius

* temperature(-273.15)

*/

public static double celsiusToFahrenheit(double c) {

final double MINIMUM_CELSIUS = -273.15;

if (c < MINIMUM_CELSIUS) {

throw new IllegalArgumentException("Argument " + c + " is too small.");

}

return (9.0/5.0)*c + 32;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值