java methods a.Write a method called kelvins that takes as i

1个回答

  • /*题目大意是写两个函数kelvins(double)和temperaturePrinter(double,double).

    kelvins 函数可以把华氏温度F转换成开氏温度K;

    temperaturePrinter函数则是打印这两个相对应的温度数值

    最后传人32F 测试一下程序.

    */

    public class Test {

    x09public static void main(String[] args) {

    x09x09double f = 32;

    x09x09double k = kelvins(32);

    x09x09temperaturePrinter(f, k);

    x09}

    x09public static double kelvins(double f){

    x09x09double k = 5*(f - 32) + 273.15;

    x09x09return k;

    x09}

    x09public static void temperaturePrinter(double f,double k){

    x09x09System.out.println(f+"F corresponds to "+k+"K");

    x09}

    }