ATM机运行代码

编程爱好者联盟 2017-03-12

实现代码:

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不久,大家帮我看一看我写错没有?

相关推荐