欢迎来到天天文库
浏览记录
ID:928345
大小:44.01 KB
页数:4页
时间:2017-09-25
《java程序设计编程题汇总》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、JAVA程序设计试卷编程题汇总1.设计一个银行帐户类Account和帐户明细类AccountDetail,AccountDetail类:属性:日期、金额;构造方法:实现对日期和金额的初始化。Account类:属性:(1)帐户信息:帐号、姓名、总金额、帐户明细(向量或数组);方法:(1)存款方法:Save(金额),将金额加入总金额,同时产生一个明细加入到帐户明细中。(2)取款方法:Fetch(金额),从总金额中减去取款金额,同时产生一个明细加入到帐户明细中。(3)构造函数:对帐号、姓名、金额赋值(帐号为任意6位
2、数字,金额为0,姓名为考生本人姓名),同时产生明细。(4)打印明细:printAccountDetail()打印所有存取记录。要求:取款返回实际取款金额,存款不返回任何值,并在Account类中添加main()方法,并在main()里进行分别进行存款2000和取款500的操作,并打印存取记录。importjava.util.*;classAccountDetail{Datedate;doublemoney;inttype;publicAccountDetail(doublem,intt){date=newDa
3、te();money=m;type=t;}}publicclassAccount{intid;Stringname;doubletotalaccount;intaccountdetailnum;Vectorv=newVector(accountdetailnum);publicAccount(intID,StringNAME){totalaccount=0;id=ID;name=NAME;accountdetailnum=0;}publicvoidSave(doublem)4JAVA程序设计试卷编程题汇总{t
4、otalaccount+=m;v.add(newAccountDetail(m,1));accountdetailnum++;}publicvoidFetch(doublem){totalaccount-=m;v.add(newAccountDetail(m,0));accountdetailnum++;}publicvoidprintAccountDetail(){AccountDetailad1=newAccountDetail(0,0);for(inti=0;i5、){ad1=(AccountDetail)v.get(i);if(ad1.type==0)System.out.println("日期:"+ad1.date+",取了"+ad1.money);elseSystem.out.println("日期:"+ad1.date+",存了"+ad1.money);}}publicstaticvoidmain(String[]args){Accounta1=newAccount(101920,"billie");a1.Save(2000);a1.Fetch(500);a1.6、printAccountDetail();}}1.设计一个APPLET类loanPay,要求用户界面如下图所示。用户在文本框中输入贷款总额,选择贷款类型后,点击“确定”按钮后,系统对用户输入的金额和贷款类型,计算20年贷款期限,每月应还款金额,将计算结果显示在相应文本框中。月还款计算公式:如果是商业贷款,月还款额=贷款总额/10000*73.91,否则月还款额=贷款总额/10000*63.75。同时写出调用该类的HTML代码。4JAVA程序设计试卷编程题汇总importjava.awt.*;importjav7、a.awt.event.*;importjava.applet.*;publicclassloanPayextendsAppletimplementsActionListener{Labella1,la2,la3;TextFieldt1,t2;Buttonb1;Checkboxcb1,cb2;CheckboxGroupcbg;Panelp1;doublemonth;//月还款publicvoidinit(){p1=newPanel();la1=newLabel("贷款总额:");la2=newLabel("贷8、款类型:");la3=newLabel("月还款:");t1=newTextField(6);t2=newTextField(6);b1=newButton("确定");cbg=newCheckboxGroup();cb1=newCheckbox("商业贷款",cbg,true);cb2=newCheckbox("公积金贷款",cbg,false);GridLayoutg1=newGridLayou
5、){ad1=(AccountDetail)v.get(i);if(ad1.type==0)System.out.println("日期:"+ad1.date+",取了"+ad1.money);elseSystem.out.println("日期:"+ad1.date+",存了"+ad1.money);}}publicstaticvoidmain(String[]args){Accounta1=newAccount(101920,"billie");a1.Save(2000);a1.Fetch(500);a1.
6、printAccountDetail();}}1.设计一个APPLET类loanPay,要求用户界面如下图所示。用户在文本框中输入贷款总额,选择贷款类型后,点击“确定”按钮后,系统对用户输入的金额和贷款类型,计算20年贷款期限,每月应还款金额,将计算结果显示在相应文本框中。月还款计算公式:如果是商业贷款,月还款额=贷款总额/10000*73.91,否则月还款额=贷款总额/10000*63.75。同时写出调用该类的HTML代码。4JAVA程序设计试卷编程题汇总importjava.awt.*;importjav
7、a.awt.event.*;importjava.applet.*;publicclassloanPayextendsAppletimplementsActionListener{Labella1,la2,la3;TextFieldt1,t2;Buttonb1;Checkboxcb1,cb2;CheckboxGroupcbg;Panelp1;doublemonth;//月还款publicvoidinit(){p1=newPanel();la1=newLabel("贷款总额:");la2=newLabel("贷
8、款类型:");la3=newLabel("月还款:");t1=newTextField(6);t2=newTextField(6);b1=newButton("确定");cbg=newCheckboxGroup();cb1=newCheckbox("商业贷款",cbg,true);cb2=newCheckbox("公积金贷款",cbg,false);GridLayoutg1=newGridLayou
此文档下载收益归作者所有