《java ATM.docx》由会员分享,可在线阅读,更多相关《java ATM.docx(7页珍藏版)》请在三一文库上搜索。
1、import java.util.*;public class ATM public static void main(String args) Login lg=new Login(); lg.show(); /登陆界面class Login /获取登录账户ID及密码 public void show() System.out.println(请输入账户ID:+ +0退出);Scanner zhid =new Scanner(System.in);String str1=zhid.nextLine();if(str1.equals(0) System.out.println(*感谢您的使用,
2、请收取您的磁卡*);System.exit(0);else System.out.println(请输入账户密码:); Scanner mm =new Scanner(System.in); String str2=mm.nextLine(); Info info=new Info(); info.check(str1,str2); /存储的用户信息class Infoint i;String user=未知,999,999,0,PuTong,聂庆亮,200981501,10010,0,PuTong,乐乐,200981511,583911,0,VIP,尹继平,200981512,1324114
3、,0,VIP;/判断用户类型public void check(String st1,String st2) boolean flag=true; for(i=0;i=0) userc3=Double.toString(Double.parseDouble(userc3)-m); try System.out.println(正在验钞,请稍后.); Thread.sleep(4000); System.out.println(:取款操作成功); catch(Exception e) System.out.println(); elseSystem.out.println(您账户的余额不足!);
4、 else System.out.println(取款金额必须是100的倍数!);return;/查询余额public void yuE(int c,String user) try Thread.sleep(1000); System.out.println(账户名:+userc0+ ID:+userc1+ +余额为:+userc3+元); catch(Exception e) System.out.println(); public void panDuan(int p,int i1,String user) switch(p) case 1:System.out.println(请输入存
5、款金额:); Scanner ckje =new Scanner(System.in);Double ck=ckje.nextDouble();this.cunKuan(i1,ck,user); break; case 2: System.out.println(请输入取款金额:); Scanner qkse =new Scanner(System.in); Double qk=qkse.nextDouble(); this.quKuan(i1,qk,user); break; case 3: this.yuE(i1,user); break; case 0: System.out.print
6、ln(*感谢您的使用,请收取您的磁卡*); System.exit(0); break; default:System.out.println(); /VIP特有转账功能public void zhuanZhang(int c,int s,double m,String user)if(Double.parseDouble(userc3)-m)=0) userc3=Double.toString(Double.parseDouble(userc3)-m); users3=Double.toString(Double.parseDouble(users3)+m); try System.out.
7、println(正在验钞,请稍后.); Thread.sleep(4000); System.out.println(:转账操作成功); catch(Exception e) System.out.println(); elseSystem.out.println(您的账户余额不足,转账失败!); public void panDuanV(int p,int i2,String user) switch(p) case 1: System.out.println(请输入存款金额:); Scanner ck1 =new Scanner(System.in); Double ck=ck1.next
8、Double(); this.cunKuan(i2,ck,user); break; case 2: System.out.println(请输入取款金额:); Scanner qk1 =new Scanner(System.in); Double qk=qk1.nextDouble(); this.quKuan(i2,qk,user); break; case 3: this.yuE(i2,user); break; case 4: System.out.println(请输入账号:); Scanner zhh =new Scanner(System.in); String zh=zhh.n
9、extLine(); for(int j=0;juser.length;j+) if(userj2.equals(zh) System.out.println(请输入金额:); Scanner zje =new Scanner(System.in); Double zj=zje.nextDouble(); this.zhuanZhang(i2,j,zj,user); return; System.out.println(此账户不存在,请核对账户信息!); return; case 0: System.out.println(*感谢您的使用,请收取您的磁卡*); System.exit(0); break; default:System.out.println(请输入要操作的选项!);