JavaATM机系统

本文档详细介绍了使用Java编程语言实现一个ATM机系统的过程,涵盖了ATM类、银行类以及账户类的设计和实现,重点讨论了如何进行账户操作、交易处理以及系统安全性的考虑。
摘要由CSDN通过智能技术生成

在这里插入图片描述

  • ATM.java


import java.util.Arrays;
import java.util.Scanner;

public class ATM {
   
    static Account account = new Account();
    static Bank bank = new Bank();
    public static void main(String[] args) {
   

        int i,type;
        Login(account.getAccountId(),account.getPassword(),account.getBalance(),account.getType());


    }
    public static void Login(String accountId[],int password[],double balance[],int type[]){
   
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入账号:");
        String user = scanner.next();
        for (int i=0;i<accountId.length;i++){
   
            if (accountId[i].equals(user)){
   
                login_pass(i,password[i],type[i]);
            }
        }
        System.out.print("账号错误,请重新");
        Login(accountId,password,balance,type);



    }

    public static void login_pass(int i,int password,int type) {
   
        int pass = 0;
        String new_pass = " ";
        Scanner scanner = new Scanner(System.in);
        while(true){
   
            System.out.println("输入密码: ");
            new_pass = scanner.next();
            try{
   
                pass =Integer.parseInt(new_pass);
            }catch (NumberFormatException e){
   
                System.out.print("密码请输入数字!");
                System.out.print("请重新");
                login_pass(i,password,type);
            }
            if(pass == password){
   
                if(type == 1){
   
                    System.out.println("欢迎你管理员");
                    admin();
                }else{
   
                    System.out.println("登录成功!");
                    user_ATM(i);
                }

            }
            System.out.print("密码错误!!!");
            System.out.print("请重新");
            login_pass(i,password,type);

        }
    }
    public static void admin(){
   
        Scanner scanner = new Scanner(System.in);
        int t = 0;
        while(true){
   
            System.out.println("请输入 1添加用户 2注销用户 3退出系统 4查询用户信息 5退出登录");
            t = scanner.nextInt();
            switch(t){
   
                case 1:
                    add();

                    break;
                case 2:
                    account.setAccountId(bank.Logout(account.getAccountId()));
                    break;
                case 3:
                    System.exit(-1);
                    break;
                case 4:
                    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值