收藏 分销(赏)

ATM银行取款系统程序代码初步.doc

上传人:仙人****88 文档编号:8744222 上传时间:2025-02-28 格式:DOC 页数:5 大小:40.04KB 下载积分:10 金币
下载 相关 举报
ATM银行取款系统程序代码初步.doc_第1页
第1页 / 共5页
ATM银行取款系统程序代码初步.doc_第2页
第2页 / 共5页


点击查看更多>>
资源描述
package atm; import java.io.*; public class perfect { public static void main(String[] args) throws IOException { System.out.println("ATM自动取款机欢迎你的光临!"); System.out.println("请输入您的密码:"); int money = 10000; int count = 0; while (count < 3) { if (login1()) { System.out.println("欢迎光临\n本ATM自动取款机为你提供如下服务:" + "\n1、 余额查询\t2、 取款\t3、 存款\t4 、 转帐\t5、 取卡"); job(money); } else { System.out.print("对不起,你输入的密码有误!"); count++; if (count == 1) { System.out.println("你已输错密码" + count + "次,注意哦,超过3次你的银行卡将被冻结!\n请重新输入:"); } if (count == 2) { System.out.println("你已输错密码" + count + "次,注意哦,你还有一次输入机会了!\n请重新输入:"); } if (count == 3) { System.out.println("你输错密码已达到" + count + "次,你的银行卡已经被冻结。\n" + "想要解冻,请带上你本人的身份证到柜台找工作人员核实以解冻,谢谢合作!"); } } } } public static boolean login1() throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); boolean result = false; if (str.equals("123456")) result = true; return result; } public static int job(int money) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str; // 定义一个字符串变量 System.out.println("请选择你要的功能:"); str = br.readLine();// 读取用户输入信息 int a = 1; // 对a值进行初始化 a = Integer.parseInt(str); if (a <= 5 && a >= 1) { if (a == 1) { System.out.println("你选择的功能是:余额查询\n"); select(money); } if (a == 2) { System.out.println("你选择的功能是:取款 \n"); outputMoney(money); select(money); } if (a == 3) { System.out.println("你选择的功能是:存款\n"); inputMoney(money); select(money); } if (a == 4) { System.out.println("你选择的功能是: 转帐\n"); moveMoney(money); select(money); } while (a == 5) { System.out.println("你选择的功能是:取卡\n"); x(); select(money); break; } } else { { System.out.println("看清楚点咯,请选择正确的选项哦\n"); job(money); } } return a; } public static int outputMoney(int x) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("请输入你取款的金额:"); int y = 0; try { y = Integer.parseInt(br.readLine()); } catch (NumberFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (y % 50 == 0 && x >= y) { x = x - y; System.out.println("尊敬的客户,你这次取了" + y + "元,你还有" + x + "元."); job(x); } if (y % 50 == 0 && x < y) { System.out.println("对不起,你输入的金额已超过你的剩余金额,请重新输入!"); job(x); } if (y % 50 != 0) { System.out.println("对不起,Atm自动取款机只能辨认面额为50倍数的金额"); outputMoney(x); } return x; } public static int inputMoney(int x) throws IOException { BufferedReader br3 = new BufferedReader( new InputStreamReader(System.in)); System.out.println("请输入你的存款金额:"); int y = 0; try { y = Integer.parseInt(br3.readLine()); } catch (NumberFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (y % 50 == 0 && x >= y) { x = x + y; System.out.println("尊敬的客户,你这次存了" + y + "元,你现有" + x + "元了."); job(x); } if (y % 50 != 0) { System.out.println("对不起,Atm自动取款机只能辨认面额为50倍数的金额"); outputMoney(x); } return x; } public static int moveMoney(int x) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("请输入你想要转出的金额:"); int y = 0; try { y = Integer.parseInt(br.readLine()); } catch (NumberFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (y % 50 == 0 && x >= y) { x = x - y; System.out.println("尊敬的客户,你这次转出了" + y + "元,你还有" + x + "元了."); job(x); } if (y % 50 == 0 && x < y) { System.out.println("对不起,你想要转出的金额已超过你的剩余金额,请重新输入!"); job(x); } if (y % 50 != 0) { System.out.println("对不起,Atm自动取款机只能辨认面额为50倍数的金额"); outputMoney(x); } return x; } public static int select(int money) throws IOException { { System.out.println("你的剩余金额为:" + money + "\n"); job(money); return money; } } public static void x() { System.out.println("欢迎你的光临,请取回你的磁卡,下次再见!\n"); } }
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 小学其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服