java methods
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/05/01 09:18:11
java methods
a.Write a method called kelvins that takes as input (that is,as argument) a temperature in degrees
Fahrenheit (of type double) and returns the temperature in degrees Kelvin (also a double).Here is the
\x09\x09\x09\x09
\x09\x09\x09
\x09\x09\x09
\x09\x09\x09\x09
\x09\x09\x09\x09\x09
mathematical formula for conversion:
\x09\x09\x09\x09
\x09\x09\x09\x09
\x09\x09\x09\x09\x09
K = 5(F −32)+273.15
9
\x09\x09\x09\x09
\x09\x09\x09
\x09\x09\x09
\x09\x09\x09
\x09\x09\x09\x09
\x09\x09\x09\x09\x09
b.Write another method called temperaturePrinter that takes as input (i.e.as argument) two doubles
and prints the following message to the screen:
\x09\x09\x09\x09\x09
F corresponds to K
where is the temperature in degrees Fahrenheit and is the corresponding temperature
\x09\x09\x09\x09\x09
in degrees Kelvin.
\x09\x09\x09\x09\x09
c.You should test your methods kelvins and temperaturePrinter in the main method by calling them
with 5 different temperatures in degrees Fahrenheit to be converted to Kelvins.Note:you will have to call
both of your methods for each temperature you pick.Also,try to pick numbers that are easy for you to check,
such as 32 F.
a.Write a method called kelvins that takes as input (that is,as argument) a temperature in degrees
Fahrenheit (of type double) and returns the temperature in degrees Kelvin (also a double).Here is the
\x09\x09\x09\x09
\x09\x09\x09
\x09\x09\x09
\x09\x09\x09\x09
\x09\x09\x09\x09\x09
mathematical formula for conversion:
\x09\x09\x09\x09
\x09\x09\x09\x09
\x09\x09\x09\x09\x09
K = 5(F −32)+273.15
9
\x09\x09\x09\x09
\x09\x09\x09
\x09\x09\x09
\x09\x09\x09
\x09\x09\x09\x09
\x09\x09\x09\x09\x09
b.Write another method called temperaturePrinter that takes as input (i.e.as argument) two doubles
and prints the following message to the screen:
\x09\x09\x09\x09\x09
F corresponds to K
where is the temperature in degrees Fahrenheit and is the corresponding temperature
\x09\x09\x09\x09\x09
in degrees Kelvin.
\x09\x09\x09\x09\x09
c.You should test your methods kelvins and temperaturePrinter in the main method by calling them
with 5 different temperatures in degrees Fahrenheit to be converted to Kelvins.Note:you will have to call
both of your methods for each temperature you pick.Also,try to pick numbers that are easy for you to check,
such as 32 F.
/*题目大意是写两个函数kelvins(double)和temperaturePrinter(double,double).
kelvins 函数可以把华氏温度F转换成开氏温度K;
temperaturePrinter函数则是打印这两个相对应的温度数值
最后传人32F 测试一下程序.
*/
public class Test {
\x09public static void main(String[] args) {
\x09\x09double f = 32;
\x09\x09double k = kelvins(32);
\x09\x09temperaturePrinter(f, k);
\x09}
\x09public static double kelvins(double f){
\x09\x09double k = 5*(f - 32) + 273.15;
\x09\x09return k;
\x09}
\x09public static void temperaturePrinter(double f,double k){
\x09\x09System.out.println(f+"F corresponds to "+k+"K");
\x09}
}
kelvins 函数可以把华氏温度F转换成开氏温度K;
temperaturePrinter函数则是打印这两个相对应的温度数值
最后传人32F 测试一下程序.
*/
public class Test {
\x09public static void main(String[] args) {
\x09\x09double f = 32;
\x09\x09double k = kelvins(32);
\x09\x09temperaturePrinter(f, k);
\x09}
\x09public static double kelvins(double f){
\x09\x09double k = 5*(f - 32) + 273.15;
\x09\x09return k;
\x09}
\x09public static void temperaturePrinter(double f,double k){
\x09\x09System.out.println(f+"F corresponds to "+k+"K");
\x09}
}
java methods
java Mutator Methods Accessor Methods
In java.()must match exactly for overloaded methods to compi
请问下在java英语中implicit parameter.Field.specify,mutator methods这
research methods是什么意思
storage methods是什么意思
Payment methods是什么意思
methods current 英语帝~
Quantitative Methods怎样翻译?THANKS
一道quantitative methods的题目
methods of missing you 中文翻译
robust analytical methods如何翻译