题目描述
if嵌套结构。
package test3_5;
import java.util.*;
public class Test3_5 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("请问你是M还是F?");
String sex=in.next();
if((sex).equals("M")){
System.out.println("你的年龄是多少?");
int age=in.nextInt();
if(age>=18){
System.out.println("成年了啊");
}
else{
System.out.println("还是个未成年啊");
}
}
else{
System.out.println("原来是个女的啊");
}
}
}