switch...case结构

it2022-05-05  97

/**switch(要判断的数据){ case 值1: ...;break; case 值2: ...;break; case 值3: ...;break; default: ...;break;}*/

publuc class employee{ int id; // 员工id String name; // 员工名字 int age; // 员工年龄 String phone; // 员工号码 String address; // 员工地址

public void showInformation(){ system.out.println("员工管理系统"); system.out.println("1.输入数据"); system.out.println("2.更新数据"); system.out.println("3.查看数据"); system.out.println("4.删除数据"); system.out.println("5.退出");

Scanner scanner = new Scanner(System.in); int chioce = scanner.nextInt();

switch(chioce){ case 1:system.ou.println("请输入数据"); break; case 2:system.ou.println("选择要更新的数据"); break; case 3:system.ou.println("输入要查看的编号"); break; case 4:system.ou.println("选择要删除的数据"); break; } } public static void main(String[] args){ employee em = new employee(); em.showInformation(); }}

转载于:https://www.cnblogs.com/pony2258/p/7677018.html


最新回复(0)