程序如下:
創(chuàng)新互聯(lián)公司是專業(yè)的渾南網站建設公司,渾南接單;提供網站設計制作、成都做網站,網頁設計,網站設計,建網站,PHP網站建設等專業(yè)做網站服務;采用PHP框架,可快速的進行渾南網站開發(fā)網頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網站,專業(yè)的做網站團隊,希望更多企業(yè)前來合作!
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class LibrarySystem
{
static ListString list = new ArrayListString();
static double money = 0;
static boolean borrow = true;
public static void doBorrow()
{
System.out.print("請輸入圖書名稱計算機書,新書:");
Scanner scanner = new Scanner(System.in);
String bookName = scanner.next();
System.out.print("請輸入圖書類型1:計算機書,2:新書:");
int type = 0;
int day = 0;
try
{
type = scanner.nextInt();
if((bookName.equals("計算機書") type != 1) ||
(bookName.equals("新書") type != 2))
{
System.out.println("類型輸入有誤,系統(tǒng)退出。");
System.exit(0);
}
} catch (RuntimeException e)
{
System.out.println("類型輸入有誤,系統(tǒng)退出。");
System.exit(0);
}
System.out.print("請輸入借閱天數(shù)(必須是整數(shù)):");
try
{
day = scanner.nextInt();
} catch (RuntimeException e)
{
System.out.println("天數(shù)輸入有誤,系統(tǒng)退出。");
System.exit(0);
}
double tempMoney = 0;
//計算租金
if(type == 1)
{
tempMoney = day*1.5;
money += tempMoney;
}
else if(type == 2)
{
tempMoney = day 3?((day-3)*2+4.5):day*1.5;
money += tempMoney;
}
list.add(MessageFormat.format("書名:{0},借閱天數(shù):{1},租金:{2}", bookName,day,tempMoney));
System.out.print("是否繼續(xù)借書(1-是,2-不是):");
try
{
type = scanner.nextInt();
while(type != 1 type != 2)
{
System.out.print("輸入有誤,請重新輸入:");
type = scanner.nextInt();
}
borrow = type == 1? true:false;
} catch (RuntimeException e)
{
System.out.println("天數(shù)輸入有誤,系統(tǒng)退出。");
}
}
public static void main(String[] args)
{
System.out.println("============歡迎使用圖書租賃管理系統(tǒng)===========");
while(borrow)
{
doBorrow();
}
System.out.println("你的借書記錄:");
System.out.println("-----------------------------------");
for(String s : list)
{
System.out.println(s);
}
System.out.println("-----------------------------------");
System.out.println("總金額:" + money);
}
}
有問題歡迎提問,滿意請采納,謝謝!
可以試試看啊
以下方法實現(xiàn)了用戶界面登陸
import java.awt.*;
import java.awt.event.*;
public class DengLuJieMian extends Frame implements ActionListener
{
Label username=new Label("用戶名:");//使用文本創(chuàng)建一個用戶名標簽
TextField t1=new TextField();//創(chuàng)建一個文本框對象
Label password=new Label("密碼:");//創(chuàng)建一個密碼標簽
TextField t2=new TextField();
Button b1=new Button("登陸");//創(chuàng)建登陸按鈕
Button b2=new Button("取消");//創(chuàng)建取消按鈕
public DengLuJieMian()
{
this.setTitle("學生信息管理系統(tǒng)");//設置窗口標題
this.setLayout(null);//設置窗口布局管理器
username.setBounds(50,40,60,20);//設置姓名標簽的初始位置
this.add(username);// 將姓名標簽組件添加到容器
t1.setBounds(120,40,80,20);// 設置文本框的初始位置
this.add(t1);// 將文本框組件添加到容器
password.setBounds(50,100,60,20);//密碼標簽的初始位置
this.add(password);//將密碼標簽組件添加到容器
t2.setBounds(120,100,80,20);//設置密碼標簽的初始位置
this.add(t2);//將密碼標簽組件添加到容器
b1.setBounds(50,150,60,20);//設置登陸按鈕的初始位置
this.add(b1);//將登陸按鈕組件添加到容器
b2.setBounds(120,150,60,20);//設置取消按鈕的初始位置
this.add(b2);// 將取消按鈕組件添加到容器
b1.addActionListener(this);//給登陸按鈕添加監(jiān)聽器
b2.addActionListener(this);// 給取消按鈕添加監(jiān)聽器
this.setVisible(true);//設置窗口的可見性
this.setSize(300,200);//設置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});//通過內部類重寫關閉窗體的方法
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)//處理登陸事件
{
String name=t1.getText();
String pass=t2.getText();
if(name!=nullpass.equals("000123"))//判斷語句
{
new StudentJieMian();
}
}
}
public static void main(String args[])//主函數(shù)
{
new DengLuJieMian();
}
}
以下方法實現(xiàn)了學生界面設計
import java.awt.*;
import java.awt.event.*;
class StudentJieMian extends Frame implements ActionListener
{
MenuBar m=new MenuBar();//創(chuàng)建菜單欄
Menu m1=new Menu("信息");//創(chuàng)建菜單“信息”
MenuItem m11=new MenuItem("插入");//創(chuàng)建“插入”的菜單項
MenuItem m12=new MenuItem("查詢");
Menu m2=new Menu("成績");//創(chuàng)建菜單“成績”
MenuItem m21=new MenuItem("查詢");
public StudentJieMian()
{
this.setTitle("學生界面");//設置窗口標題
this.setLayout(new CardLayout());//設置窗口布局管理器
this.setMenuBar(m);//將菜單欄組件添加到容器
m.add(m1);//將信息菜單放入菜單欄
m.add(m2);
m1.add(m11);//將“插入”菜單項添加到“信息”菜單
m1.add(m12); //將“查詢”菜單項添加到“信息”菜單
m2.add(m21); //將“查詢”菜單項添加到“成績”菜單
m11.addActionListener(this); //給“插入”菜單項添加監(jiān)聽器
m12.addActionListener(this); //給“查詢”菜單項添加監(jiān)聽器
m21.addActionListener(this); //給“查詢”菜單項添加監(jiān)聽器
this.setVisible(true); //設置窗口的可見性
this.setSize(300,200); //設置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);//關閉窗口
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==m11) //處理“添加信息”事件
{
new AddStudent();
}
if(e.getSource()==m12) //處理“查詢信息”事件
{
new SelectStudent();
}
if(e.getSource()==m21) //處理“查詢成績”事件
{
new ChengJiStudent();
}
}
public static void main(String args[])
importjava.text.SimpleDateFormat;\x0d\x0aimportjava.util.Date;\x0d\x0aimportjava.util.Scanner;\x0d\x0a\x0d\x0a/*********************************\x0d\x0a*停車場管理\x0d\x0a*authorzhang\x0d\x0a*2013-12-13\x0d\x0a********************************/\x0d\x0apublicclassCarStopManager{\x0d\x0a\x0d\x0apublicstaticvoidmain(String[]args){\x0d\x0aScannersc=newScanner(System.in);\x0d\x0a\x0d\x0aSystem.out.println("請入車牌號:");\x0d\x0aStringcarno=sc.next();\x0d\x0aCarStopManagercarStopManager=newCarStopManager();\x0d\x0acarStopManager.setCarNo(carno);//設置車牌號\x0d\x0a\x0d\x0aSimpleDateFormatformat=newSimpleDateFormat("yyyy-MM-ddHH:mm:ss");\x0d\x0aStringsdate=format.format(newDate());\x0d\x0aSystem.out.println("當前時間(入場時間)是:"+sdate);\x0d\x0a\x0d\x0aSystem.out.println("需要開出車場嗎?yes/no:");\x0d\x0aStringyesno=sc.next();\x0d\x0a\x0d\x0aif(yesno.equals("yes")){\x0d\x0aStringedate=format.format(newDate());\x0d\x0aSystem.out.println("出場時間是:"+edate);\x0d\x0a//計算方法\x0d\x0acarManager(2,sdate,edate,carStopManager);\x0d\x0a}\x0d\x0a}\x0d\x0a/**\x0d\x0a*計算方法\x0d\x0a*/\x0d\x0apublicstaticvoidcarManager(inttype,StringstarTime,\x0d\x0aStringendTime,CarStopManagercarStopManager){\x0d\x0a\x0d\x0aif(type==1){//按月收費\x0d\x0aSystem.out.println("如若沒有繳納月費請繳納800元,如若繳納將不再提示!");\x0d\x0a}else{\x0d\x0a/**\x0d\x0a*一般不會有停車幾個月的吧?先不考慮停車幾年或者幾個月的\x0d\x0a*/\x0d\x0aStringsDay=starTime.substring(8,10);//入場日期(天)\x0d\x0aStringsHour=starTime.substring(11,13);//入場小時\x0d\x0aStringsMM=starTime.substring(14,16);//入場分鐘\x0d\x0a\x0d\x0aStringeDay=starTime.substring(8,10);//出場日期(天)\x0d\x0aStringeHour=endTime.substring(11,13);//出廠小時\x0d\x0aStringeMM=endTime.substring(14,16);//出廠分鐘\x0d\x0a\x0d\x0afloatmoney=0;//需繳納的費用\x0d\x0aintshour=Integer.parseInt(sHour);\x0d\x0aintehour=Integer.parseInt(eHour);\x0d\x0aintsmm=Integer.parseInt(sMM);\x0d\x0aintemm=Integer.parseInt(eMM);\x0d\x0aintrehour=0;//停車幾個小時\x0d\x0a\x0d\x0aif(sDay.equals(eDay)){//同一天\x0d\x0a//當天6點到20點之間\x0d\x0aif((shour=6shour
回答于?2022-12-14
世紀站長網
盟動力源碼
365源碼之家
天新網
豆豆源碼
這樣的網站多了,去看看吧。
網站標題:免費java系統(tǒng)源代碼 java源代碼網站
分享鏈接:http://muchs.cn/article46/doshihg.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供網站建設、品牌網站建設、標簽優(yōu)化、網站設計公司、App設計、網頁設計公司
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)