请教个JAVA题目

来源:百度知道 编辑:UC知道 时间:2024/05/29 02:09:43
说明一个存储一年的每天气温的数组,数组长度为365,数组中数据元素的类型为float。请编写如下java程序:1.本年的最热和最冷的天数; 2.每月的平均温度; 3.每月的最热和最冷天数之间的差别; 4.查找出给定天的气温。
注意:有两种有效的输入值:月从1到12,天从1到31.不允许输入第13个月或第32天这样的无效值。
谢谢 实在不会。。。
好的加分

最热温度的天数
public class Test {
//自己改为365天~
private static final float[] S_WENDU = {
1, 2, 3, 4, 15, 6, 4, 3, 2, 1};

private static float s_max;

private static int k;

/**
* @param args
*/
public static void main(String[] args) {
for (int i = 0; i < S_WENDU.length - 1; i++) {
if (S_WENDU[i + 1] >= S_WENDU[i]) {
s_max = S_WENDU[i + 1];
k = i + 2;
}
}
System.out.println("第" + k + "天:" + s_max + "度");
}
}