欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

java地址簿管理系统

程序员文章站 2022-11-15 20:20:00
import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class AA {List list=new ArrayList();private void a() {System.out.println(“欢迎使用地址簿管理系统=");System.out.println();while (true) {System.out.print("1:查找地址 " + " ");System...

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class AA {
List list=new ArrayList();
private void a() {
System.out.println(“欢迎使用地址簿管理系统=");
System.out.println();
while (true) {
System.out.print("1:查找地址 " + " ");
System.out.print("2:添加地址 " + " ");
System.out.print("3:删除地址 " + " ");
System.out.print("4:修改地址 " + " ");
System.out.print(“5:查看所有地址” + " “);
System.out.println(“0:退出”);
System.out.println();
System.out.println(“请选择你要执行的操作”);
String input = new Scanner(System.in).next();
switch (input) {
case “1”:
System.out.println(“查看地址*”);
System.out.println(“请输入你要查找的地址”);
String intput = new Scanner(System.in).next();
if (list.contains(intput)) {
System.out.println(“查找到地址:”+intput);
}
else {
System.out.println(“未查到该地址”);
}
System.out.println(”
");
break;
case “2”:
System.out.println(“添加地址”);
System.out.println(“请输入你要添加的地址”);
String A = new Scanner(System.in).next();
list.add(A);
System.out.println(“添加成功”);
System.out.println("
");
break;
case “3”:
System.out.println(“删除地址”);
System.out.println(“请输入你要删除的地址”);
String B = new Scanner(System.in).next();
list.remove(B);
System.out.println(“删除成功”);
System.out.println("
");
break;
case “4”:
System.out.println(“修改地址”);
System.out.println(“请输入你要修改的地址”);
String C = new Scanner(System.in).next();
list.remove©;
System.out.println(“请输入更改后的地址”);
String change = new Scanner(System.in).next();
list.add(change);
System.out.println(“修改成功”);
System.out.println("
");
break;
case “5”:
System.out.println(“查看地址”);
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
System.out.println("
============================================”);
break;
case “0”:
System.out.println("*****欢迎下次使用,再见!");
return;
default:
System.out.println("!!!输入序号有误,重新选择!!!");
break;
}
}

    }
 public static void main(String[] args) {
	new ad().a();
}

}

本文地址:https://blog.csdn.net/laoliusm/article/details/107390130

相关标签: java java