急!两个Java编程题 华氏度和摄氏度互相转换和48小时员工工资
发布网友
发布时间:2022-04-25 16:29
我来回答
共1个回答
热心网友
时间:2023-10-17 20:28
一、
public class test01 {
public static void main(String[] args) {
double centigrade = FtoC(78);
System.out.println(centigrade);
double fahrenheit = CtoF(78);
System.out.println(fahrenheit);
}
public static double FtoC(double F) {
double C;
C = (5.0/9) * (F - 32);
return C;
}
public static double CtoF(double C) {
double F;
F = (9.0/5) * C + 32;
return F;
}
}
二、
public class test02 {
public static void main(String[] args) {
double remuneration = Salary(48);
System.out.println(remuneration);
}
public static double Salary(int hour) {
double wages = 0;
if(hour <= 40){
wages = hour * 20;
}
if(hour > 40){
wages = 40 * 20 + (hour - 40) * 20 * 1.5;
}
return wages;
}
}