public class Test {
private static Scanner in = null;
public static String getName(){
String name = "";
in = new Scanner(System.in);
System.out.println("Entername : ");
name = in.nextLine();
return name;
}
public static int getAge(){
int age = 0;
in = new Scanner(System.in);
System.out.println("Enterage : ");
age = in.nextInt();
return age;
}
public static int compareAge( int age1 , int age2){
return age1 - age2;
}
public static void main(String[] args) {
String nameA = getName();
int ageA = getAge();
String nameB = getName();
int ageB = getAge();
int compare = compareAge(ageA,ageB);
if( compare0 ){
System.out.println( nameA +" is order than " + nameB + " by " + compare + "year");
}else if( compare0 ){
System.out.println(nameA +" is younger than " + nameB + " by " + compareAge(ageB,ageA) + " year");
}
}
}
Java怎么判断岁数代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java判断年龄是否成年、Java怎么判断岁数代码的信息别忘了在本站进行查找喔 。
推荐阅读
- 用友erp系统教程bom,用友erp系统软件
- 电脑做ppt怎么修改,电脑做ppt怎么改背景
- 快手张大仙斗鱼直播视频,斗鱼主播张大仙
- ads怎么连接mysql ads怎么连线
- 短视频app官方下载安卓,短视频app安卓版下载
- 控制台csgo国外服务器指令,csgo怎么调外服指令
- pdf讲义转excel,pdf讲义转为PPT
- go语言yaml配置 go语言 ui
- 无人机拍摄泰国首都叫什么,泰国可以带无人机吗