//switch分支用法
/*public class Zuoye5{
public static void main(String[] args){
System.out.println(“欢迎来到自动拨号系统”);
int num =(int)(Math.random()8);
switch (num){
case 1:;
System.out.println(“拨打爸爸的号”+num);break
case 2 :;
System.out.println(“拨打妈妈的号”+num);break
case 3:;
System.out.println(“拨打爷爷的号”+num);break
case 4:;
System.out.println(“拨打奶奶的号”+num);break
default:System.out.println(“对不起,没有该号码”);
}
}
}/
//if分支用法
import java.util.Scanner;
public class Zuoye5{
public static void main(String[] args){
System.out.println(“欢迎来到自动拨号系统”);
System.out.println(“请输入快捷数字”);
Scanner sc =new Scanner(System.in);
int num=sc.nextInt();
if(num==1){
System.out.println(“爸爸的电话”);
}else if(num==2){
System.out.println("妈妈的电话");
}else if(num==3){
System.out.println("爷爷的电话");
}else if(num==4){
System.out.println("奶奶的电话");
}
}
}