返回首页

求编程大师指点,为什么一点回车就提示程序停止工作啊?

238 2024-04-23 11:13 admin

一、求编程大师指点,为什么一点回车就提示程序停止工作啊?

楼主你好 我估计是你的跳转代码或是执行代码没有写对 一旦进入执行状态就会死循环,请检查你的代码

以上回答希望对你有帮助

二、我想请教各位java编程大师,如何获取本地ip并显示在文本框中

可以直接用下面语句获得IP地址

String ip = InetAddress.getLocalHost().getHostAddress();

三、哪一位编程大师帮我用java写一份图书馆管理系统,

运行一下看要不要咯。

package booksborrow;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

class Student{

String number;

String name;

String[] booksName=new String[4];

int booksNum;

public Student(String number,String name,String booksName,int booksNum){

this.number=number;

this.name=name;

this.booksNum=booksNum;

for(int i=0;i<4;i++) {

this.booksName[i]=new String();

}

}

}

class Books{

static String bname[]={红楼梦,西游记,三国演义,水浒传,聊斋志异,

java编程经典,数字电子技术,老人与海,电子商务,子夜,中国十大皇帝,

邓小平文选,鲁迅散文全集,空蝉,商法,刑法,民法,数据库导论,

管理信息系统,财务管理,统计学,线性代数,离散数学,逻辑学,

高等代数};

static String biden[]=new String[bname.length+1];

static int[] bnum=new int[bname.length+1];

public Books(){

for(int i=0;i<bname.length;i++){

bnum[i]=7;

switch(i/10){

case 0:biden[i]=112200+i;break;

case 1:

case 2:

case 3:biden[i]=11220+i;break;

}

}

}

boolean count(String books_identifier,int borr_or_retur){

final int borr=0;

final int retur=1;

int i;

for(i=0;biden[i]!=null;i++) {

if(biden[i].equals(books_identifier)) {

break;

}

}

if(biden[i]==null){

System.out.println(\t\t**********无此书!**********);

return false;

}

else if(borr_or_retur==borr) {

if(bnum[i]==0){

System.out.println(\t\t*****此书已全部被借走!*****);

return false;

}

else {

bnum[i]--;

}

}

else {

bnum[i]++;

}

return true;

}

}

class Borrow{

public void borrow(String number,String name,String booksName,String books_identifier,Student[] stu,Books book){

int i,j;

boolean judge=false;

for(i=0;!.equals(stu[i].number) || stu[i].number.equals(-1);i++) {

if(stu[i].number.equals(number) || stu[i].name.equals(name)){judge=true;break;}

}

if(stu[i].booksNum>=4) {

System.out.println(\t对不起,您所借的图书已达到上限,请还书后再继续借书!);

}

else if(book.count(books_identifier,0)) {

if(judge==false) {

stu[i].number=number;

stu[i].name=name;

stu[i].booksName[0]=booksName;

stu[i].booksNum=1;

}

else{

for(j=0;!stu[i].booksName[j].equals() && !stu[i].booksName[j].equals(-1);j++);

stu[i].booksName[j]=booksName;

stu[i].booksNum++;

}

}

}

}

class Return{

public void retur(String number,String name,String booksName,String books_identifier,Student[] stu,Books book){

int i,j;

for(i=0;!.equals(stu[i].name) || stu[i].name.equals(-1);i++) {

if(stu[i].name.equals(name)) {

break;

}

}

if(.equals(stu[i].name)) {

System.out.println(\t\t**请核实: 您之前并未借书!**);

}

else if(book.count(books_identifier,1)){

for(j=0;!stu[i].booksName[j].equals() || stu[i].booksName[j].equals(-1);j++) {

if(stu[i].booksName[j].equals(booksName)){

stu[i].booksName[j]=-1;

break;

}

}

stu[i].booksNum--;

if(stu[i].booksNum==0){

stu[i].number=-1;

stu[i].name=-1;

}

}

}

}

class BooksBorrow{

public static void main(String[] args){

Student[] stu=new Student[100000];

String number;

String name;

String booksName;

String books_identifier;

int going=0;

int conti;

int title=0;

Books book=new Books();

Borrow bo=new Borrow();

Return re=new Return();

for(int i=0;i<100000;i++) {

stu[i]=new Student(,,,0);

}

do{

System.out.print(\t\t请从以下菜单中选择操作:\n\t\t\t1---------查询图书馆藏

+ 书概况\n\t\t\t2---------借书\n\t\t\t3---------还书\n\t\t请输入:);

try{BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

title=Integer.parseInt(br.readLine());

}catch(IOException | NumberFormatException e){}

if(title==1){

System.out.println(图书馆藏书概况如下:\n编号\t\t 书名\t\t 可借阅本数);

try{for(int i=0;Books.bname[i]!=null;i++) {

System.out.println(Books.biden[i]+\t\t+Books.bname[i]+\t\t+Books.bnum[i]);

}

}catch(ArrayIndexOutOfBoundsException e){}

}

else if(title==2) {

try{System.out.print(t********************借书*******************\n\t\t请输入学号:);

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

number=br.readLine();

System.out.print(\t\t请输入姓名:);

name=br.readLine();

do

{System.out.print(\t\t请输入书号:);

books_identifier=br.readLine();

System.out.print(\t\t请输入书名:);

booksName=br.readLine();

bo.borrow(number,name,booksName,books_identifier,stu,book);

System.out.print(\t\t是否继续(1--Y/0--N请输入1或0): );

conti=Integer.parseInt(br.readLine());

}while(conti==1);

}catch(IOException | NumberFormatException e){System.err.println(e);}

}

else if(title==3) {

try{System.out.print(\t********************还书********************\n\t\t请输入学号:);

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

number=br.readLine();

System.out.print(\t\t请输入姓名:);

name=br.readLine();

do

{System.out.print(\t\t请输入书号:);

books_identifier=br.readLine();

System.out.print(\t\t请输入书名:);

booksName=br.readLine();

re.retur(number,name,booksName,books_identifier,stu,book);

System.out.print(\t\t是否继续(1--Y/0--N请输入1或0): );

conti=Integer.parseInt(br.readLine());

}while(conti==1);

}catch(IOException | NumberFormatException e){System.err.println(e);}

}

else {

System.out.println(\t\t*********输入错误*********!);

}

try{System.out.print(是否退出(1--Y/0--N请输入1或0):);

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

going=Integer.parseInt(br.readLine());

}catch(IOException | NumberFormatException e){}

}while(going==0);

}

}

200分

我是来看分的

200个积分能干什么。、

有具体要求吗?

顶一下
(0)
0%
踩一下
(0)
0%
相关评论
我要评论
用户名: 验证码:点击我更换图片