double english=60.5;
double math=70.0;
double chinese=80.0;
double course=Math.max(english, math);
double top=Math.max(course, chinese);
System.out.println("成绩最高的科目:"+top);
运行结果: 80.0我想将运行结果 是成绩最高的那一门所对应的科目,即输出Chinese,而不是最高科目的分数80.0,该怎么办?
double math=70.0;
double chinese=80.0;
double course=Math.max(english, math);
double top=Math.max(course, chinese);
System.out.println("成绩最高的科目:"+top);
运行结果: 80.0我想将运行结果 是成绩最高的那一门所对应的科目,即输出Chinese,而不是最高科目的分数80.0,该怎么办?
解决方案 »
- java的时间监听问题,如何实现自动的监听呢
- 数据还原
- 我是Java初学者,想请教各位达人,你们帮帮我啊!
- 大家觉得要把JAVA基础扎实了,至少看哪些书 ?
- 客户端收不到服务器端的信息.(两个用户)
- 高手请进,时间同步问题:如何更改另一IP的机器上的时间?
- jbuild中能不能象微软vb,vc,.net一样,出错时可以停在出错的地方,类似在vb中break on all Errors
- ¥¥¥¥¥¥¥我的时间几乎都是在这打发的,感谢各位朋友!散分!!######
- 为什么会这样?
- 学习哪个技术比较好?
- jdbc 连接sql2000提示java.lang.classnotfoundexception: com.microsoft.jdbc.sqlserver.
- 如何清除swt中画的线?
System.out.println("成绩最高的科目:"+map.get(top));
public static void main(String[] args){
double[] score={60.5,70.0,80.0,74,65};
String[] course={"English","Math","Chinese","Music","Drawing"};
int maxIndex=max(score);
System.out.println("最高分是:"+course[maxIndex]+" : "+score[maxIndex]);
}
public static int max(double[] score){
int maxIndex=0;
for(int i=1;i<score.length;i++){
if(score[i]>score[maxIndex]){
maxIndex=i;
}
}
return maxIndex;
}
}
F:\java>java Test4
最高分是:Chinese : 80.0
public class t0{
private static int max( double f[]){
double MaxValue = f[0];
int max = 0;
for (int i=1;i<f.length; i++)
if (MaxValue < f[i]){
MaxValue = f[i];
max = i;
}
return max;
}
public static void main(String args[]) {
String name[]= {"english","math","chinese"};
double score[] = {60.5,70.0,80.0};
System.out.println("成绩最高的科目:"+ name[max(score)]);;
}
}