java怎么if,if else,if else if eles,三种语句实现求出三个值的最大值

2024-11-23 04:56:11
推荐回答(3个)
回答(1):

public class 求最大值 { public static void main(String[] args) {
double a,b,c;
double max;
a=89;
b=30;
c=40;

if (a>=b)
max=a;
else
max=b;

if (max max=c;

System.out.println("最大值是"+max);
}}

回答(2):

int a=12,b=34,c=33,max=a;if(a>b){ if(a>c){ max=a; }else{ max=c; }}else{ if(b>c){ max=b; }else{ max=c; }}

回答(3):

int a=1,b=2,c=3;if (a>b) { if (a>c) System.out.println(a); else if (c>b) System.out.println(c);}else if (c>b) System.out.println(c);else System.out.println(b);