发布网友 发布时间:2022-04-22 06:52
共4个回答
热心网友 时间:2022-06-16 23:51
import java.util.*;
class Temp{
double Trans(double f){
double c=(5/9)*(f-32);
return c;
}
}
public class Temperature{
public static void main(String[] args){
Temp t=new Temp();
Scanner scan=new Scanner(System.in);
System.out.println("输入华氏温度");
double f=scan.nextInt();
double c=t.Trans(f);
System.out.println("摄氏温度为"+c);
}
}
热心网友 时间:2022-06-16 23:51
public class Temperature {
public int changeTemperature(int F_temperature) {
int C_temperature;
C_temperature = (5 / 9) * (F_temperature - 32);
return C_temperature;
}
public static void main(String[] args) {
int C_temperature = new Temperature().changeTemperature(20);
System.out.println(C_temperature);
}
}
你确定你给的公式对? 那样的公式将永远返回0.
5/9就永远得0,在乘以任何数结果还是0. 不过代码我给你了,看着自己改吧。
热心网友 时间:2022-06-16 23:52
public class temperature
{
/**
*
* @param F
* @return
*/
static double exchange(double F)
{
double C;
C=5*(F-32)/9;
return C;
}
/**
*
* @param args
*/
public static void main(String[] args)
{
double temperature=55;//所要转换的华氏温度数
System.out.println(temperature+"'F等于"+exchange(temperature)+"'C");
}
}
请采纳
热心网友 时间:2022-06-16 23:53
public class test{
public int fTOc (int f){
int c = 0;
c = (5/9)*(f-32),
return c;
}
public static void main (string[] args){
int f = 50;
test ftoc = new test();
int c = ftoc.fTOc(f);
System.out.println(c);
}
}