導航:首頁 > 編程語言 > javaatm課程設計報告

javaatm課程設計報告

發布時間:2023-05-05 18:12:43

Ⅰ 急求一份java課程設計,結課大作業,最近有考試,時間不夠,來不及做了。謝謝啦!郵箱573762475@qq.com

Java課程設計報告
題 目: 計算器
院(系):xxx學院
年級專業: xxx班
學生姓名: xxx
指導老師: xx老師
開始時間: 200x-xx-xx
完成時間: 200x-xx-xx
目 錄
1. 摘 要
2. 概要設計
3. 詳細設計
4. 測試分析
5. 參考文獻
一、摘 要
本計算器可以進行簡單的四則運算(加、減、乘、除)但僅限於十進制下,還可以進行(八進制,十進制,十六進制)之間的相互轉換,八進制最多可以輸入19位數,十進制最多可以輸入18位數,十六進制最多可以輸入14位數,backspace表示退格, clear表示初始化,在window下直接運行(jsp2003.bat)即可,界面為灰白對稱。
二、概要設計
(1) 自定義類說明
**********************************************************
* 類名: This_number_too_big *
* 作用: 自定義的異常類,用來處理計算結果溢出 *
* 繼承的父類: Exception類 *
* 實現的介面: 沒有 *
**********************************************************
class This_number_too_big extends Exception
{
}//自定義的一個結果溢出異常類
**********************************************************
* 類名: Jsp2003 *
* 作用: 主類。 *
* 繼承的父類: Frame類 *
* 實現的介面: ItemListener類,ActionListener類 *
**********************************************************
class Jsp2003 extends Frame implements ItemListener,ActionListener
{
public int number=0,length=18;
//number是用來記錄輸入的數字個數,
//length是用來設置在不同進制下允許輸入的最多數字位數,默認為十進制 public char mark='n';
//設置運算符號為沒有即為『n』,它的值是『+』『-』『*』『/』
public double data=0;
//設置運算數據為零
public char ch;
//用來臨時存放所按按鈕的第一個字元
public boolean Refresh=false;
//設置lab是否要在輸入數據的時候刷新,初始為否
主要方法說明:
------------------------------------------------------------------------------------------------
//用來處理按了運算符後的計算-
public void js() throws This_number_too_big //指定由method拋出異常
{if (mark=='n') //沒有運算符
{mark=ch; //,則設置運算符為剛剛輸入的字元,
data=Double.parseDouble(lab.getText());//則設置運算數據為lab的值
Refresh=true;//則設置下一次輸入的時候要刷新lab
}
else //如果採用的是連續運算(即沒有使用『=』號)則運行下面的語句
{switch (mark) //根據運算符計算結果,並把結果保存到data
{ case '+': data+=Double.parseDouble(lab.getText()); break;
case '-': data-=Double.parseDouble(lab.getText()); break;
case '*': data*=Double.parseDouble(lab.getText()); break;
case '/': data/=Double.parseDouble(lab.getText()); break;}
lab.setText(Double.toString(data)); //顯示運算結果
mark=ch;//設置運算符為剛剛按下的運算符
Refresh=true;//則設置下一次輸入的時候要刷新lab
number=lab.getText().length();//設置輸入的字元個數
// System.out.println(lab.getText());//用來調試用的
if (data>Double.MAX_VALUE)
//如果data超過double類型的最大值則拋出自定義的一個異常類

}
}//end js() method
----------------------------------------------------------------------------------------------------
public void enter()//處理輸入字元
{if(Refresh==true)
//如果已經設置了 運算符則在下一次輸入數據的時候要把以前lab的內容清除掉

if(lab.getText().charAt(0)=='0'&& lab.getText().length()==1)
//如果lab的內容為0則,lab的內容將被所輸入的字元代替,
//否則直接在lab的內容後面加上所輸入的字元

else
if(number<length)

}//end enter() method
--------------------------------------------------------------------------------------------------------
//八進制或十六進制轉換成十進制I
public String goto_10(String s,long l)
//參數s: 是要轉換的字元串,由於輸入的控制,保證了字元串的合法性;
//參數l: 使用來設置是將8進制還是16進制轉換成10進制,它的有效值為8或16;
{ String str=s; //用來轉換的字元串
long j=l; //表示進制
long lg=0,jing=1;//lg用來記錄權乘和,jing用來記錄位權
char cha;//臨時記錄要轉換的字元
for(int i=1;i<=str.length();i++)
{ cha=str.charAt(str.length()-i);
switch(cha)
{ case '1': lg=lg+1*jing;break;
case '2': lg=lg+2*jing;break;
case '3': lg=lg+3*jing;break;
case '4': lg=lg+4*jing;break;
case '5': lg=lg+5*jing;break;
case '6': lg=lg+6*jing;break;
case '7': lg=lg+7*jing;break;
case '8': lg=lg+8*jing;break;
case '9': lg=lg+9*jing;break;
case 'A': lg=lg+10*jing;break;
case 'B': lg=lg+11*jing;break;
case 'C': lg=lg+12*jing;break;
case 'D': lg=lg+13*jing;break;
case 'E': lg=lg+14*jing;break;
case 'F': lg=lg+15*jing;break;}
jing*=j; //位權升一級,為下次使用做好准備
}
return Long.toString(lg);
}//end String goto_10() method
}
(2)程序流程圖

三、詳細設計
import java.awt.*;
import java.awt.event.*;
class This_number_too_big extends Exception
{}//自定義的一個結果溢出異常類
class Jsp2003 extends Frame implements ItemListener,ActionListener {
public Jsp2003() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
}
static Jsp2003 mainFrame = new Jsp2003();
static Label lab=new Label("0");
static Panel pnl1=new Panel(new GridLayout(4,3,3,3));
static Panel pnl2=new Panel(new GridLayout(4,1,3,3));
static Panel pnl3=new Panel(new GridLayout(1,2,3,3));
static Panel pnl4=new Panel(new GridLayout(6,1,3,3));
static Button bt9=new Button("9");
static Button bt8=new Button("8");
static Button bt7=new Button("7");
static Button bt6=new Button("6");
static Button bt5=new Button("5");
static Button bt4=new Button("4");
static Button bt3=new Button("3");
static Button bt2=new Button("2");
static Button bt1=new Button("1");
static Button bt0=new Button("0");
static Button btdot=new Button(".");
static Button btequ=new Button("=");
static Button btadd=new Button("+");
static Button btsub=new Button("-");
static Button btmul=new Button("*");
static Button btdev=new Button("/");
static Button btA=new Button("A");
static Button btB=new Button("B");
static Button btC=new Button("C");
static Button btD=new Button("D");
static Button btE=new Button("E");
static Button btF=new Button("F");
static Checkbox ckb8=new Checkbox("八進制");
static Checkbox ckb10=new Checkbox("十進制");
static Checkbox ckb16=new Checkbox("十六進制");
static Button btc=new Button("clear");
static Button btt=new Button("backspace");
public int number=0,length=18;
//number是用來記錄輸入的數字個數,length是用來設置在不同進制下允許輸入的最多數字位數,默認為十進制
public char mark='n'; //設置運算符號為沒有即為『n』,它的值是『+』『-』『*』『/』
public double data=0; //設置運算數據為零
public char ch; //用來臨時存放所按按鈕的第一個字元
public boolean Refresh=false;//設置lab是否要在輸入數據的時候刷新,初始為否
public static void main(String args[]) {
System.out.println("Starting Jsp2003...");
lab.setAlignment(Label.RIGHT);
lab.setBackground(Color.lightGray);
lab.setForeground(Color.BLUE);
lab.setFont(new Font("Serief",Font.BOLD,18));
lab.setBounds(14,33,216,40);
mainFrame.add(lab);
CheckboxGroup grp=new CheckboxGroup();
ckb8.setCheckboxGroup(grp);
ckb10.setCheckboxGroup(grp);
ckb16.setCheckboxGroup(grp);
ckb8.setBounds(14,75,55,25);
ckb10.setBounds(69,75,55,25);
ckb16.setBounds(124,75,65,25);
ckb8.setState(false);
ckb10.setState(true);
ckb16.setState(false);
mainFrame.add(ckb8);
mainFrame.add(ckb10);
mainFrame.add(ckb16);
pnl1.setBounds(14,140,120,150);
pnl2.setBounds(144,140,40,150);
pnl3.setBounds(14,100,170,36);
pnl4.setBounds(190,100,40,190);
pnl1.add(bt7);
pnl1.add(bt8);
pnl1.add(bt9);
pnl1.add(bt4);
pnl1.add(bt5);
pnl1.add(bt6);
pnl1.add(bt1);
pnl1.add(bt2);
pnl1.add(bt3);
pnl1.add(bt0);
pnl1.add(btdot);
pnl1.add(btequ);
pnl2.add(btadd);
pnl2.add(btsub);
pnl2.add(btmul);
pnl2.add(btdev);
pnl3.add(btt);
pnl3.add(btc);
pnl4.add(btA);
pnl4.add(btB);
pnl4.add(btC);
pnl4.add(btD);
pnl4.add(btE);
pnl4.add(btF);
btA.enable(false);
btB.enable(false);
btC.enable(false);
btD.enable(false);
btE.enable(false);
btF.enable(false);
mainFrame.add(pnl1);
mainFrame.add(pnl2);
mainFrame.add(pnl3);
mainFrame.add(pnl4);
mainFrame.setResizable(false);
mainFrame.setLayout(null);
mainFrame.setSize(240,300 );
mainFrame.setTitle("計算器");
mainFrame.setVisible(true);
ckb8.addItemListener(mainFrame);
ckb10.addItemListener(mainFrame);
ckb16.addItemListener(mainFrame);
//把事件聆聽者向各個組鍵注冊
bt1.addActionListener(mainFrame);
bt2.addActionListener(mainFrame);
bt3.addActionListener(mainFrame);
bt4.addActionListener(mainFrame);
bt5.addActionListener(mainFrame);
bt6.addActionListener(mainFrame);
bt7.addActionListener(mainFrame);
bt8.addActionListener(mainFrame);
bt9.addActionListener(mainFrame);
bt0.addActionListener(mainFrame);
btadd.addActionListener(mainFrame);
btsub.addActionListener(mainFrame);
btmul.addActionListener(mainFrame);
btdev.addActionListener(mainFrame);
btt.addActionListener(mainFrame);
btc.addActionListener(mainFrame);
btdot.addActionListener(mainFrame);
btequ.addActionListener(mainFrame);
btA.addActionListener(mainFrame);
btB.addActionListener(mainFrame);
btC.addActionListener(mainFrame);
btD.addActionListener(mainFrame);
btE.addActionListener(mainFrame);
btF.addActionListener(mainFrame);
}// end main() mothed
//---------------------------------------------
//checkbox 事件的處理
public void itemStateChanged(ItemEvent e)
{ mark='n';
Refresh=false;
//規定當進制轉換時以前輸入的運算符失效
if (ckb8.getState()==true)
{ btA.enable(false);
btB.enable(false);
btC.enable(false);
btD.enable(false);
btE.enable(false);
btF.enable(false);
bt9.enable(false);
bt8.enable(false);
btdot.enable(false);
btadd.enable(false);
btmul.enable(false);
btsub.enable(false);
btdev.enable(false);
btequ.enable(false);
//在八進制的情況下對有些按件的管理
if(length==18) { lab.setText(goto10_8(lab.getText()));
number=lab.getText().length();
}
if(length==14) { lab.setText(goto_10(lab.getText(),16L));
lab.setText(goto10_8(lab.getText()));
number=lab.getText().length();
}
//將其他進制轉換成八進制
length=19;
//在八進制下允許輸入數字個數最多為19位
}
if(ckb10.getState()==true)
{ btA.enable(false);
btB.enable(false);
btC.enable(false);
btD.enable(false);
btE.enable(false);
btF.enable(false);
bt9.enable(true);
bt8.enable(true);
btdot.enable(true);
btadd.enable(true);
btmul.enable(true);
btsub.enable(true);
btdev.enable(true);
btequ.enable(true);
//在十進制的情況下對有些按件的管理
if(length==19) { lab.setText(goto_10(lab.getText(),8L));
number=lab.getText().length();}
if(length==14) { lab.setText(goto_10(lab.getText(),16L));
number=lab.getText().length();}
//進制轉換成十進制
length=18;
//在十進制下允許輸入數字個數最多為18位
}
if(ckb16.getState()==true)
{ btA.enable(true);
btB.enable(true);
btC.enable(true);
btD.enable(true);
btE.enable(true);
btF.enable(true);
bt9.enable(true);
bt8.enable(true);
btdot.enable(false);
btadd.enable(false);
btmul.enable(false);
btsub.enable(false);
btdev.enable(false);
btequ.enable(false);
//在十六進制的情況下對有些按件的管理
if(length==18) { lab.setText(goto10_16(lab.getText()));
number=lab.getText().length();}
if(length==19) { lab.setText(goto_10(lab.getText(),8L));
lab.setText(goto10_16(lab.getText()));
number=lab.getText().length();}
//將其他進制轉換成十六進制
length=14;
//在十六進制下允許輸入數字個數最多為14位
}
}//end itemStateChanged(ItemEvent e) method
//------------------------------------------------------------
//按鈕事件的處理
public void actionPerformed(ActionEvent m)
{
Button btn=(Button) m.getSource();
ch=btn.getLabel().charAt(0);
switch (ch)
break;//初始化
case '1': enter(); break;
case '2': enter(); break;
case '3': enter(); break;
case '4': enter(); break;
case '5': enter(); break;
case '6': enter(); break;
case '7': enter(); break;
case '8': enter(); break;
case '9': enter(); break;
case '0':
if(lab.getText().charAt(0)=='0'&& lab.getText().length()==1)
break;
if(number<length)
else break;
} break;
case 'A': enter(); break;
case 'B': enter(); break;
case 'C': enter(); break;
case 'D': enter(); break;
case 'E': enter(); break;
case 'F': enter(); break;
case '.': {if(Refresh==true)
if(lab.getText().indexOf('.')== -1)

else
break;
}
break;
case 'b': {if(number==0) break;
else

else
{if (number!=1) lab.setText(lab.getText().substring(0,number));
else
lab.setText(Character.toString(lab.getText().charAt(0)));}
}
}break;
case '+': try

catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出現異常則初始化效果如同clear鍵
case '-': try

catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出現異常則初始化效果如同clear鍵
case '*': try

catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出現異常則初始化效果如同clear鍵
case '/': try

catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出現異常則初始化效果如同clear鍵
case '=': try

catch(This_number_too_big e)
{lab.setText("0"); number=0; mark='n';
Refresh=false; System.out.println("The number is too big");} break;
//如果出現異常則初始化效果如同clear鍵
}

Ⅱ 急!Java 題庫維護系統課程報告

importjava.io.BufferedReader;
importjava.io.BufferedWriter;
importjava.io.File;
importjava.io.FileReader;
importjava.io.FileWriter;
importjava.io.IOException;
importjava.text.SimpleDateFormat;
importjava.util.ArrayList;
importjava.util.Date;
importjava.util.List;
importjava.util.Scanner;


publicclassMain{
publicstaticfinalStringDATE_FORMAT="MM月dd日";
=newScanner(System.in);
publicstaticList<Item>itemList=null;
="d:/item.txt";
publicstaticinttotal;
privatestaticintcurrent=1;

publicstaticvoidmain(String[]args){
try{
process();
}catch(IOExceptione){
e.printStackTrace();
}
}

privatestaticvoidinit()throwsIOException{
itemList=ItemReaderWriter.readItemsFromFile(itemPath);
total=itemList.size();
}

privatestaticvoidprocess()throwsIOException{
show();
Stringc=getInput();
while(!c.equals("a")&&!c.equals("i")&&!c.equals("d")&&!c.equals("l")){
System.err.println("輸入錯誤!請輸入a/i/d/l");
process();
}

if("a".equals(c)){
aOperation();
}
elseif("i".equals(c)){
iOperation();
}
elseif("d".equals(c)){
dOperation();
}
elseif("l".equals(c)){
lOperation();
}

}
privatestaticvoidprint(String...msg){
if(msg!=null&&msg.length>0){
System.out.println(msg[0]);
}
else{
System.out.println();
}
}
private緩燃staticStringgetDateNow(){
SimpleDateFormatsdf=new神哪友SimpleDateFormat(DATE_FORMAT);
returnsdf.format(newDate());
}
privatestaticvoidshow(){
print("/********************************************************/");
StringdateStr游槐=getDateNow();
print("題庫維護系統今天"+dateStr+"..........");
print("請選擇相關操作:");
print("1.添加題目按鍵盤字元(a)");
print("2.導入題目按鍵盤字元(i)");
print("3.刪除題目按鍵盤字元(d)");
print("4.顯示題目按鍵盤字元(l)");
print("/********************************************************/");
}
privatestaticvoidaOperation()throwsIOException{
init();
print("***********************************************************");
print("添加題目,題庫已有試題"+total+"條,當前錄入第"+current+"條");
print("***********************************************************");
print("請輸入題目:");
Stringtitle=(total+1)+"."+getInput();
print("請輸入選項A:");
Stringa="A."+getInput();
print("請輸入選項B:");
Stringb="B."+getInput();
print("請輸入選項C:");
Stringc="C."+getInput();
print("請輸入選項D:");
Stringd="D."+getInput();

Itemitem=newItem(title,a,b,c,d);
System.out.println(item);
ItemReaderWriter.writeToFile(item,itemPath);
total+=1;
current+=1;

print("輸入成功,否繼續輸入?(y/n)");
Strings=getInput();
if("y".equals(s)){
aOperation();
}
else{
process();
}
}

privatestaticvoidiOperation()throwsIOException{
init();
print("請輸入需要導入題庫文件路徑:");
Stringpath=getInput();
Filef=newFile(path);
if(!f.exists()){
thrownewIOException("不是一個有效的路徑!");
}
else{
try{
ItemReaderWriter.importToFile(itemPath,path,total);
print("題庫導入成功!");
}catch(Exceptione){
System.err.println("題庫導入失敗!"+e.getMessage());
e.printStackTrace();
}
}
process();
}

privatestaticvoiddOperation()throwsIOException{
init();
print("***********************************************************");
print("刪除題目");
print("***********************************************************");
print("請輸入所需刪除題號:");
StringnumStr=getInput();
intnum=0;
try{
num=Integer.valueOf(numStr);

ItemReaderWriter.deleteByNum(itemPath,num);
print("刪除試題成功!");
}catch(NumberFormatExceptione){
System.err.println("輸入的不是有效的題號!");
e.printStackTrace();
}catch(IOExceptionee){
System.out.println("刪除題目失敗!"+ee);
ee.printStackTrace();
}
process();
}

privatestaticvoidlOperation()throwsIOException{
init();
print("***********************************************************");
if(itemList==null||itemList.size()==0){
print("目前題庫中沒有題目!");
return;
}
print("目前題庫中共有"+itemList.size()+"道試題!");
for(inti=0;i<itemList.size();i++){
Itemitem=itemList.get(i);
print(item.getTitle());
print(item.getA());
print(item.getB());
print(item.getC());
print(item.getD());
print();
}
print("***********************************************************");
process();
}

privatestaticStringgetInput(){
Stringcstr=scanner.next();
while(cstr==null||cstr.trim().length()==0){
print("請輸入內容!");
cstr=scanner.next();
}
returncstr;
}


}

finalclassItemReaderWriter{
//假定題目的格式如下:
//題目表述:
//選項A:
//選項B:
//選項C:
//選項D:
//1道題有5行組成
publicstaticList<Item>readItemsFromFile(StringfilePath)throwsIOException{
Filef=newFile(filePath);
if(!f.exists()){
f.createNewFile();
}
List<Item>itemList=newArrayList<Item>();
BufferedReaderbr=newBufferedReader(newFileReader(filePath));
Stringline=null;

while((line=br.readLine())!=null){
//標題
Stringtitle=line;
//選項A
Stringa=line=br.readLine();
//選項B
Stringb=line=br.readLine();
//選項C
Stringc=line=br.readLine();
//選項D
Stringd=line=br.readLine();
Itemitem=newItem(title,a,b,c,d);
itemList.add(item);

//空行,每題之間空一行
line=br.readLine();
}
returnitemList;
}

(Itemitem,StringfilePath)throwsIOException{
FileWriterfw=newFileWriter(filePath,true);
if(Main.itemList!=null&&Main.itemList.size()>=0){
//空行,題目之間空一行
fw.write(" ");
}
//標題
fw.write(item.getTitle());
fw.write(" ");
//選項A
fw.write(item.getA());
fw.write(" ");
//選項B
fw.write(item.getB());
fw.write(" ");
//選項C
fw.write(item.getC());
fw.write(" ");
//選項D
fw.write(item.getD());
fw.close();
}

publicstaticvoidimportToFile(StringitemPath,StringfilePath,inttotal)throwsIOException{
BufferedReaderbr=newBufferedReader(newFileReader(newFile(filePath)));
Stringline=null;

while((line=br.readLine())!=null){
//標題
Stringtitle=line;
if(title.matches("^\d+.*$")){
title=title.replaceFirst("\d+","");
title=(++total)+title;
}
//選項A
Stringa=line=br.readLine();
//選項B
Stringb=line=br.readLine();
//選項C
Stringc=line=br.readLine();
//選項D
Stringd=line=br.readLine();
Itemitem=newItem(title,a,b,c,d);
writeToFile(item,itemPath);

//讀取下一個空行
line=br.readLine();
}
br.close();
}

(StringfilePath,intnum)throwsIOException{
List<Item>itemList=readItemsFromFile(filePath);
booleanfind=false;
if(itemList!=null&&itemList.size()>0){
for(Itemitem:itemList){
if(item.getTitle().startsWith(Integer.toString(num))){
find=true;
itemList.remove(item);
break;
}
}
}
else{
System.out.println("題庫中沒有試題");
}

if(find){
BufferedWriterbw=newBufferedWriter(newFileWriter(newFile(filePath)));
for(inti=0;i<itemList.size();i++){
Itemitem=itemList.get(i);
//標題
Stringtitle=item.getTitle();
title=title.replaceFirst("\d+","");
title=(i+1)+title;
bw.write(title);
bw.write(" ");
//選項A
bw.write(item.getA());
bw.write(" ");
//選項B
bw.write(item.getB());
bw.write(" ");
//選項C
bw.write(item.getC());
bw.write(" ");
//選項D
bw.write(item.getD());

if(i!=itemList.size()-1){
bw.write(" ");
}
}
bw.close();
}
}
}

classItem{
privateStringtitle;
privateStringa;
privateStringb;
privateStringc;
privateStringd;

publicItem(){

}
publicItem(Stringtitle,Stringa,Stringb,Stringc,Stringd){
this.title=title;
this.a=a;
this.b=b;
this.c=c;
this.d=d;
}
publicStringgetTitle(){
returntitle;
}
publicvoidsetTitle(Stringtitle){
this.title=title;
}
publicStringgetA(){
returna;
}
publicvoidsetA(Stringa){
this.a=a;
}
publicStringgetB(){
returnb;
}
publicvoidsetB(Stringb){
this.b=b;
}
publicStringgetC(){
returnc;
}
publicvoidsetC(Stringc){
this.c=c;
}
publicStringgetD(){
returnd;
}
publicvoidsetD(Stringd){
this.d=d;
}
@Override
publicStringtoString(){
return"Item[title="+title+",a="+a+",b="+b+",c="+c
+",d="+d+"]";
}
}

Ⅲ 跪求一個JAVA課程設計, 學生信息管理系統 含全源代碼 設計報告

import java.awt.*;
import java.awt.event.*;
public class DengLuJieMian extends Frame implements ActionListener
{
Label username=new Label("用戶名:");//使用文本創建一個用戶名標簽
TextField t1=new TextField();//創建一個文本框對象
Label password=new Label("密碼:");//創建一個密碼標簽
TextField t2=new TextField();
Button b1=new Button("登陸");//創建登陸按鈕
Button b2=new Button("取消");//創建取消按鈕
public DengLuJieMian()
{
this.setTitle("學生信息管理系統");//設置窗口標題
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);//給登陸按鈕添加監聽器
b2.addActionListener(this);// 給取消按鈕添加監聽器

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!=null&&pass.equals("000123"))//判斷語句
{
new StudentJieMian();
}
}
}
public static void main(String args[])//主函數
{
new DengLuJieMian();
}
}
以下方法實現了學生界面設計
import java.awt.*;
import java.awt.event.*;
class StudentJieMian extends Frame implements ActionListener
{
MenuBar m=new MenuBar();//創建菜單欄
Menu m1=new Menu("信息");//創建菜單「信息」
MenuItem m11=new MenuItem("插入");//創建「插入」的菜單項
MenuItem m12=new MenuItem("查詢");
Menu m2=new Menu("成績");//創建菜單「成績」
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); //給「插入」菜單項添加監聽器
m12.addActionListener(this); //給「查詢」菜單項添加監聽器
m21.addActionListener(this); //給「查詢」菜單項添加監聽器
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[])
{ new StudentJieMian(); //創建一個對象 }

Ⅳ Java課程設計,模擬銀行存取業務,按照這個流程圖去做,其實最主要的是求畫圈的部分怎麼寫和它的方法。

請點擊輸入圖片描述

package com.greatwall.business.controller;


import java.math.BigDecimal;

import java.util.Scanner;

import java.util.regex.Matcher;

import java.util.regex.Pattern;


/**

* @author xysddjyt

* @since 2020/6/16 15:06

*/

public class BankTest {


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

// 余額(單位:分)

Long BALANCE = 10000000L;


// 卡號

String card = "001";


// 密碼

String password = "123456";


String inputCard = new String();

String inputPassword = new String();

String quit = new String();

while (true) {

System.out.println(" 歡迎來到網上銀行辦理存取款業務!");

System.out.println("請輸入銀行卡號和銀行卡密碼進行登錄!");

while (true) {

System.out.print("請輸入銀行卡號(按q退出): ");

inputCard = scan.nextLine();

quit = inputCard;

if (inputCard.equals("q")) {

break;

}

if (!inputCard.equals(card)) {

System.out.print("您輸入銀行卡號不正確,請重新輸入 ");

continue;

}

break;

}

if (quit.equals("q")) {

continue;

}

while (true) {

System.out.print("請輸入銀行卡密碼(按q退出): ");

inputPassword = scan.nextLine();

quit = inputPassword;

if (inputPassword.equals("q")) {

break;

}

if (!inputPassword.equals(password)) {

System.out.print("您輸入銀行卡密碼不正確,請重新輸入 ");

continue;

}

break;

}

if (quit.equals("q")) {

continue;

}

System.out.print("登錄成功,當前登錄的賬戶名:" + inputCard);

String type = "4";

while (!type.equals("0")) {

System.out.print(" 您當前的余額為:" + money(BALANCE) + "元");

System.out.print(" 請選擇操作類型。(存款:1;取款:2 ;余額:3;退出:0) ");

type = scan.nextLine();

switch (type) {

case "1": {

System.out.print("請輸入您的存款金額(元):");

String chageNumber = scan.nextLine();

if (!isPositiveInteger(chageNumber)) {

System.out.print("請輸入正確的存款金額!");

continue;

}

BALANCE = Long.valueOf(chageNumber) * 100 + BALANCE;

continue;

}

case "2": {

System.out.print("請輸入您的取款金額(元):");

String chageNumber = scan.nextLine();

if (!isPositiveInteger(chageNumber)) {

System.out.print("請輸入正確取款金額!");

continue;

}

BALANCE = BALANCE - Long.valueOf(chageNumber) * 100;

continue;

}

case "3": {

System.out.print("您當前的余額為:" + money(BALANCE) + "元 ");

continue;

}

default: {

continue;

}

}

}

}

}


private static boolean isMatch(String regex, String orginal) {

if (orginal == null || orginal.trim().equals("")) {

return false;

}

Pattern pattern = Pattern.compile(regex);

Matcher isNum = pattern.matcher(orginal);

return isNum.matches();

}

// 判斷數據是否為正整數

public static boolean isPositiveInteger(String orginal) {

return isMatch("^\+{0,1}[1-9]\d*", orginal);

}

// 分轉元,轉換為bigDecimal在toString

public static String money(Long money) {

return BigDecimal.valueOf(money).divide(new BigDecimal(100)).toString();

}

}

Ⅳ 《Java程序設計》課程設計報告 表達式求值

import java.awt.*;
import java.applet.*;

public class DrawRound extends Applet implements Runnable {
int r;
int x,y;
public void init() {
x=(int)(Math.random()*getWidth());//隨機坐標
y=(int)(Math.random()*getHeight());
setSize(800,800);
r=10;//初始半徑=10
}
public void start() {
new Thread(this).start();//建立新線程
}
public void run() {
try {
while(true){
r =10;
if(r==150){//當半徑=150時重新定義坐標,同時半徑等於初始狀態10
r=10;
x=(int)(Math.random()*getWidth()/2);
y=(int)(Math.random()*getHeight()/2);
}
Thread.sleep(500);//半徑每隔0.5秒就自動 10
repaint();//每次半徑變化時清空原來所畫的圓
}

}
catch(Exception e) {}

}
public void paint(Graphics g) {
g.setColor(new Color((int)(Math.random()*255), (int)(Math.random()*255), (int)(Math.random()*255)));//隨機顏色
g.fillOval(x,y,r,r);//畫圓
}
}

Ⅵ 用java編寫銀行賬戶的存款方法

[xxx計算銀行利息攜悶的java程序.rar] - 此程序是java語言編寫的,關於銀行計算利息的控制台程序。再加工一下可以作為J2EE的一個JAVABEAN組件。非常有使用價值。 [一個經典的五子棋程序.rar] - 用java做的五子棋。非常經典。適合初學者參考! [ICcardmanager.rar] - 使用java編寫的一個銀行信用卡管理系統,簡單實用。 [bankqueue.rar] - java編寫的一個多線程程序,模擬銀行排隊. [RILSample.rar] - windows mobile 6下查詢ril層信號強度的例子程序,需要在ppc上運行 [分享Swing學習的一些經驗.rar] - 分享Swing學習的一些經驗 ,入門之後的書籍推薦如下。 [BankAccount.rar] - 由java寫的一個銀行賬岩笑戶系統,該系統可以記錄賬戶的操作:存款,取款,以及累計余額等! [1136643381605java-29-.rar] - 用java語言編寫的銀行管理系統,包括完整的開發流程和文檔。 [atm.rar] - 課程設計:ATM Project源碼,有四個獨立程序,銀行端,貨物公司端,辯棗彎ATM取款機端,自動售貨機端,應該可以算四個,還有一個VC寫的配置ODBC的源嗎,另外,請求一個帳號用於下載源嗎 文件列表(點擊判斷是否您需要的文件,如果是垃圾請在下面評價投訴): exercise6-2 ...........\banking ...........\.......\Account.class ...........\.......\Account.java ...........\.......\Bank.class ...........\.......\Bank.java ...........\.......\CheckingAccount.class ...........\.......\CheckingAccount.java ...........\.......\Customer.class ...........\.......\Customer.java ...........\.......\SavingsAccount.class ...........\.......\SavingsAccount.java ...........\TestBanking.class ...........\TestBanking.java

Ⅶ 《Java》期末課程設計

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class QuestionOne {

/**
* 編程將從鍵盤輸入文本中的子字元串「word」替換為字元串「world」, 並刪除所有的子字元串「this」。
* 序程要求:程序中要包含局遲有注釋,對於使用的變數和方法的功能要加以說明。
*/
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));

String message = null; // 存儲用戶輸瞎臘友入的字元磨槐串
try {
while ((message = reader.readLine()) != null) {
// 列印處理前的字元串
System.out.println("輸入的字元串為:" + message);

// 把 word 替換為 world
message = message.replaceAll("word", "world");

// 把 this 替換為 空
message = message.replaceAll("this", "");

// 列印處理後的字元串
System.out.println("處理後為:" + message);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("出現異常,程序退出!");
}
}
}

Ⅷ 用java軟體里的eclipse編ATM取款機(課程設計)

這個嘛,基本上很難

Ⅸ !高分跪求幫忙寫一個簡單小程序的JAVA課程設計報告(內詳!!)

連連看java源代碼
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianliankan implements ActionListener
{
JFrame mainFrame; //主面板
Container thisContainer;
JPanel centerPanel,southPanel,northPanel; //子面板
JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數組
JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕
JLabel fractionLable=new JLabel("0"); //分數標簽
JButton firstButton,secondButton; //分別記錄兩次被選中的按鈕
int grid[][] = new int[8][7];//儲存游戲按鈕位置
static boolean pressInformation=false; //判斷是否有按鈕被選中
int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標
int i,j,k,n;//消除方法控制
public void init(){
mainFrame=new JFrame("JKJ連連看");
thisContainer = mainFrame.getContentPane();
thisContainer.setLayout(new BorderLayout());
centerPanel=new JPanel();
southPanel=new JPanel();
northPanel=new JPanel();
thisContainer.add(centerPanel,"Center");
thisContainer.add(southPanel,"South");
thisContainer.add(northPanel,"North");
centerPanel.setLayout(new GridLayout(6,5));
for(int cols = 0;cols < 6;cols++){
for(int rows = 0;rows < 5;rows++ ){
diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));
diamondsButton[cols][rows].addActionListener(this);
centerPanel.add(diamondsButton[cols][rows]);
}
}
exitButton=new JButton("退出");
exitButton.addActionListener(this);
resetButton=new JButton("重列");
resetButton.addActionListener(this);
newlyButton=new JButton("再來一局");
newlyButton.addActionListener(this);
southPanel.add(exitButton);
southPanel.add(resetButton);
southPanel.add(newlyButton);
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));
northPanel.add(fractionLable);
mainFrame.setBounds(280,100,500,450);
mainFrame.setVisible(true);
}
public void randomBuild() {
int randoms,cols,rows;
for(int twins=1;twins<=15;twins++) {
randoms=(int)(Math.random()*25+1);
for(int alike=1;alike<=2;alike++) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
}
this.grid[cols][rows]=randoms;
}
}
}
public void fraction(){
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));
}
public void reload() {
int save[] = new int[30];
int n=0,cols,rows;
int grid[][]= new int[8][7];
for(int i=0;i<=6;i++) {
for(int j=0;j<=5;j++) {
if(this.grid[i][j]!=0) {
save[n]=this.grid[i][j];
n++;
}
}
}
n=n-1;
this.grid=grid;
while(n>=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6+1);
rows=(int)(Math.random()*5+1);
}
this.grid[cols][rows]=save[n];
n--;
}
mainFrame.setVisible(false);
pressInformation=false; //這里一定要將按鈕點擊信息歸為初始
init();
for(int i = 0;i < 6;i++){
for(int j = 0;j < 5;j++ ){
if(grid[i+1][j+1]==0)
diamondsButton[i][j].setVisible(false);
}
}
}
public void estimateEven(int placeX,int placeY,JButton bz) {
if(pressInformation==false) {
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
pressInformation=true;
}
else {
x0=x;
y0=y;
fristMsg=secondMsg;
firstButton=secondButton;
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
if(fristMsg==secondMsg && secondButton!=firstButton){
xiao();
}
}
}
public void xiao() { //相同的情況下能不能消去。仔細分析,不一條條注釋
if((x0==x &&(y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)&&(y0==y))){ //判斷是否相鄰
remove();
}
else{
for (j=0;j<7;j++ ) {
if (grid[x0][j]==0){ //判斷第一個按鈕同行哪個按鈕為空
if (y>j) { //如果第二個按鈕的Y坐標大於空按鈕的Y坐標說明第一按鈕在第二按鈕左邊
for (i=y-1;i>=j;i-- ){ //判斷第二按鈕左側直到第一按鈕中間有沒有按鈕
if (grid[x][i]!=0) {
k=0;
break;
}
else{ k=1; } //K=1說明通過了第一次驗證
}
if (k==1) {
linePassOne();
}
}
if (y<j){ //如果第二個按鈕的Y坐標小於空按鈕的Y坐標說明第一按鈕在第二按鈕右邊
for (i=y+1;i<=j ;i++ ){ //判斷第二按鈕左側直到第一按鈕中間有沒有按鈕
if (grid[x][i]!=0){
k=0;
break;
}
else { k=1; }
}
if (k==1){
linePassOne();
}
}
if (y==j ) {
linePassOne();
}
}
if (k==2) {
if (x0==x) {
remove();
}
if (x0<x) {
for (n=x0;n<=x-1;n++ ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0 && n==x-1) {
remove();
}
}
}
if (x0>x) {
for (n=x0;n>=x+1 ;n-- ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0 && n==x+1) {
remove();
}
}
}
}
}
for (i=0;i<8;i++ ) { //列
if (grid[i][y0]==0) {
if (x>i) {
for (j=x-1;j>=i ;j-- ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x<i) {
for (j=x+1;j<=i;j++ ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x==i) {
rowPassOne();
}
}
if (k==2){
if (y0==y) {
remove();
}
if (y0<y) {
for (n=y0;n<=y-1 ;n++ ) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0 && n==y-1) {
remove();
}
}
}
if (y0>y) {
for (n=y0;n>=y+1 ;n--) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0 && n==y+1) {
remove();
}
}
}
}
}
}
}
public void linePassOne(){
if (y0>j){ //第一按鈕同行空按鈕在左邊
for (i=y0-1;i>=j ;i-- ){ //判斷第一按鈕同左側空按鈕之間有沒按鈕
if (grid[x0][i]!=0) {
k=0;
break;
}
else { k=2; } //K=2說明通過了第二次驗證
}
}
if (y0<j){ //第一按鈕同行空按鈕在與第二按鈕之間
for (i=y0+1;i<=j ;i++){
if (grid[x0][i]!=0) {
k=0;
break;
}
else{ k=2; }
}
}
}
public void rowPassOne(){
if (x0>i) {
for (j=x0-1;j>=i ;j-- ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
if (x0<i) {
for (j=x0+1;j<=i ;j++ ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
}
public void remove(){
firstButton.setVisible(false);
secondButton.setVisible(false);
fraction();
pressInformation=false;
k=0;
grid[x0][y0]=0;
grid[x][y]=0;
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==newlyButton){
int grid[][] = new int[8][7];
this.grid = grid;
randomBuild();
mainFrame.setVisible(false);
pressInformation=false;
init();
}
if(e.getSource()==exitButton)
System.exit(0);
if(e.getSource()==resetButton)
reload();
for(int cols = 0;cols < 6;cols++){
for(int rows = 0;rows < 5;rows++ ){
if(e.getSource()==diamondsButton[cols][rows])
estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);
}
}
}
public static void main(String[] args) {
lianliankan llk = new lianliankan();
llk.randomBuild();
llk.init();
}
}

//old 998 lines
//new 318 lines
參考資料:http://..com/question/36439800.html?fr=qrl3

閱讀全文

與javaatm課程設計報告相關的資料

熱點內容
桌面雲配置文件分離 瀏覽:505
iphone5如何升級4g網路 瀏覽:5
團購是在哪個app 瀏覽:897
打開多個word文檔圖片就不能顯示 瀏覽:855
騰訊新聞怎麼切換版本 瀏覽:269
app安裝失敗用不了 瀏覽:326
桌面文件滑鼠點開會變大變小 瀏覽:536
手機誤刪系統文件開不了機 瀏覽:883
微信兔子甩耳朵 瀏覽:998
android藍牙傳文件在哪裡 瀏覽:354
蘋果6s軟解是真的嗎 瀏覽:310
c語言代碼量大 瀏覽:874
最新網路衛星導航如何使用 瀏覽:425
以下哪些文件屬於圖像文件 瀏覽:774
zycommentjs 瀏覽:414
確認全血細胞減少看哪些數據 瀏覽:265
文件有哪些要求 瀏覽:484
cad打開時會出現兩個文件 瀏覽:65
什麼是轉基因網站 瀏覽:48
手柄設備有問題代碼43 瀏覽:921

友情鏈接