ATM机运行代码
实现代码:
import java.util.Scanner; public class Atm { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); System.out.println("欢迎来到中国银行ATM系统中心"); System.out.println("请登录"); String user,pwd; float money =500; for (int i = 3 ; i > 0 ; i--){ System.out.println("请输入用户名:"); String checkUser = sc.next(); System.out.println("请输入密码:"); String checkPwd = sc.next(); if (user.equals (checkUser) && pwd.equals(checkPwd)){ System.out.println("登录成功"); return true; }else{ if(i == 1){ System.out.println("你的卡被吞,请找相关人员"); return false; }System.out.println("密码错误!还有" + (i - 1) + "次机会"); } }return false; System.out.println("1 查询余额,2 取款, 3 存款 "); int a = sc.nextInt(); switch(a){ case 1: break; case 2: break; case 3: break; Public static float saveMoney(){ System.out.println("你的余额为:" + money); }Public static float getMoney(float money){ System.out.println("请输入取款金额:"); float Money = sc.nextFloat(); if(getMoney <= 500){ System.out.println("取款成功"); }else{ System.out.println("取款不成功"); } } Public static float saveMoney(){ System.out.println("请输入存款金额"); Scanner sc = new Scanner (System.in); float saveMoney = sc.nextFloat(); if (savsMoney <= 500){ System.out.println("存款成功"); }else{ System.out.println("存款不成功"); } }break; System.out.println("是否退卡?"); } } }
我才学习JAVA不久,大家帮我看一看我写错没有?
相关推荐
labulakayoyo 2020-05-22
DMusic 2019-04-12
laopolu 2013-10-12
RuifengZeng 2011-06-14
pengkunstone 2019-04-10
鹤之淇水 2019-03-06
NSSpeak信息安全 2018-11-27
jick 2018-02-09
零到无限远 2018-11-16
sudoyc 2011-05-17
beifenggo 2014-03-25
lylzsu 2012-07-06
yionhiou 2010-08-17
lispython 2019-01-29
xuke0 2010-04-15
0lzqth 2009-07-08
软件架构师何志丹 2010-02-05
AloneVivian 2010-01-28