import java.util.*;
public class hhh
{
public static void main(String[] args)
{
int a=12345,b=10086;
boolean yunxing=true;
String [] bookName={"红楼梦","西游记","水浒传","三国演义"};
System.out.println("**********图书馆系统管理**********");
Scanner reader = new Scanner(System.in);
System.out.println("请输入五位数用户名: ");
a=reader.nextInt();
System.out.println("请输入五位密码: ");
b=reader.nextInt();
if (a==12345&&b==10086)
{
System.out.println("输入正确\n");
while (yunxing)
{
System.out.println("请选择菜单:6--查找、7--添加、8--删除、0--退出 ");
int d=reader.nextInt();
switch (d)
{
//第一部分 查找
case 6:
System.out.println("\n\n当前图书\n");
for (int i=0; i<bookName.length; i++)
{
System.out.println((i+1)+bookName[i]);
}
System.out.println("\n\n查找书籍\n");
System.out.println("请输入编号: ");
int c=reader.nextInt();
if (c>0&&c<=bookName.length)
{
System.out.println("该书籍为:"+bookName[c-1]);
}
break;
//第三部分 添加
case 7:
System.out.println("\n\n用户输入添加的书籍为: \n");
int n=reader.nextInt();
String newBook="儒林外传";
String [] insArray=new String [bookName.length+1];
for (int i=0; i<bookName.length; i++)
{
insArray[i]=bookName[i];
}
insArray[insArray.length-1]=newBook;
bookName=insArray;
for (int i=0; i<bookName.length; i++)
{
System.out.println(bookName[i]);
}
System.out.println("\n");
break;
//第四分部 删除
case 8:
System.out.println("\n\n用户输入删除的书籍为:\n");
int j=reader.nextInt();
int delBookID=2;
String [] delArray=new String [bookName.length-1];
for (int i=delBookID; i<bookName.length-1; i++)
{
bookName[i]=bookName[i+1];
}
for (int i=0; i<delArray.length; i++)
{
delArray[i]=bookName[i];
}
bookName=delArray;
for (int i=0; i<bookName.length; i++)
{
System.out.println(bookName[i]);
}break;
//第五部分 退出
case 0:
yunxing=false;
}
}
}
else
{
System.out.println("输入有误,请重新输入!");
}
}
} 急
qq_苏安
相关分类