int sum=24+18+36+27;
double avg=sum/4;
int minus=24-18;
int newAge=24-1;
double avg=sum/4;
int minus=24-18;
int newAge=24-1;
2015-07-04
这是我的:
int sum=age1+age2+age3+age4;
double avg=sum/4;
int minus=age1-age2;
int newAge=--age1;
System.out.println("年龄总和:"+sum);
System.out.println("平均年龄:"+avg);
System.out.println("年龄差值:"+minus);
System.out.println("自减后的年龄:"+newAge);
int sum=age1+age2+age3+age4;
double avg=sum/4;
int minus=age1-age2;
int newAge=--age1;
System.out.println("年龄总和:"+sum);
System.out.println("平均年龄:"+avg);
System.out.println("年龄差值:"+minus);
System.out.println("自减后的年龄:"+newAge);
2015-07-04
public class HelloWorld {
public static void main(String[] args) {
int score = 94;
String sex = "女";
if(score>80){
if(sex="女"){System.out.println("进入女子组决赛");}
else(sex!="女"){System.out.println("进入男子组决赛");}
else {
System.out.println("未进入决赛");
}
}
public static void main(String[] args) {
int score = 94;
String sex = "女";
if(score>80){
if(sex="女"){System.out.println("进入女子组决赛");}
else(sex!="女"){System.out.println("进入男子组决赛");}
else {
System.out.println("未进入决赛");
}
}
2015-07-03
public class HelloWorld {
public static void main(String[] args) {
int age=25;
if(age>60){System.out.println("老年");}
else if(age>=40&&age<=60){System.out.println("中年");}
else(age>=18&&age<40){System.out.println("少年");}
if(age<18){System.out.println("童年");}
}
}
public static void main(String[] args) {
int age=25;
if(age>60){System.out.println("老年");}
else if(age>=40&&age<=60){System.out.println("中年");}
else(age>=18&&age<40){System.out.println("少年");}
if(age<18){System.out.println("童年");}
}
}
2015-07-03