當前位置:編程學習大全網 - 源碼下載 - JAVA圖書租賃系統源代碼

JAVA圖書租賃系統源代碼

該過程如下:

導入Java . text . message format;

導入Java . util . ArrayList;

導入Java . util . list;

導入Java . util . scanner;

公共類庫系統

{

靜態列表& lt字符串& gtlist = new ArrayList & lt字符串& gt();

靜態雙幣= 0;

靜態布爾借=真;

公共靜態void doBorrow()

{

System.out.print("請輸入圖書名稱:");

Scanner scanner =新掃描儀(system . in);

string bookName = scanner . next();

System.out.print("請輸入圖書類型;:");

int type = 0;

int day = 0;

嘗試

{

type = scanner . nextint();

If((bookName.equals("電腦書")&;& amp打字!= 1) ||

(bookName.equals("新書")&;& amp打字!= 2))

{

System.out.println("類型輸入錯誤,系統退出。");

system . exit(0);

}

} catch (RuntimeException e)

{

System.out.println("類型輸入錯誤,系統退出。");

system . exit(0);

}

System.out.print("請輸入借閱天數(必須是整數):");

嘗試

{

day = scanner . nextint();

} catch (RuntimeException e)

{

System.out.println("天數輸入錯誤,系統退出。");

system . exit(0);

}

double temp money = 0;

//計算租金

if(type == 1)

{

temp money = day * 1.5;

money+= temp money;

}

else if(type == 2)

{

tempMoney = day & gt3?((天-3)*2+4.5):天* 1.5;

money+= temp money;

}

list . add(message format . format(" title:{ 0 },借閱天數:{1},租金:{2}”,bookName,day,temp money));

System.out.print("繼續借書(1-是,2-否):");

嘗試

{

type = scanner . nextint();

while(類型!= 1。& amp打字!= 2)

{

System.out.print("輸入錯誤,請重新輸入:");

type = scanner . nextint();

}

borrow = type == 1?真:假;

} catch (RuntimeException e)

{

System.out.println("天數輸入錯誤,系統退出。");

}

}

公共靜態void main(String[] args)

{

系統。out . println(" = = = = = = = = = =歡迎使用圖書租賃管理系統= = = = = = ");

while(借)

{

doBorrow();

}

System.out.println("妳的借閱記錄:");

system . out . println("-");

for(字符串s:列表)

{

system . out . println(s);

}

system . out . println("-");

System.out.println("總金額:"+金錢);

}

}

如果妳有任何問題,請問他們。如果妳滿意,請采納它們。謝謝大家!

  • 上一篇:鄭源歌曲
  • 下一篇:Cadcass源代碼
  • copyright 2024編程學習大全網