ATM机

本文详细探讨了ATM(自动取款机)的工作原理,包括其硬件组成部分、软件系统、安全机制以及与银行系统的交互流程。同时,还讨论了现代ATM机中采用的最新技术,如生物识别和移动支付集成。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

public class Account {
    private int id;
    private double balance = 100;

    public Account(int id, double money) {
        this.id = id;
        this.balance = money;
    }


    public double getBalance() {
        return balance;
    }

    public void withDraw(double value) {
        balance = balance - value;
    }

    public void deposit(double value) {
        balance = balance + value;
    }
    public int getId (){
        return id;
    }


}

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
       Account[] accounts = new Account[10];
       for (int i=0;i<10;i++){
           accounts[i]=new Account(i,100);
       }
        while (true) {
            System.out.print("Enter the id: ");
            Scanner input = new Scanner(System.in);
            int in = input.nextInt();
            if (in < 0 || in > 9) {
                System.out.println("ERROR ID");
                continue;
            }
            Account account = accounts[in];
            System.out.println(account.getId());
            boolean stop = false;

            while (!stop) {
                System.out.println("\nMain menu");
                System.out.printf("%-15s\n%-15s\n%-15s\n%-15s\n", "1: check balance", "2: withdraw", "3: deposit", "4: exit");
                System.out.print("Enter a choice: ");

                switch (input.nextInt()) {
                    case 1:
                        System.out.println("The balance is " + account.getBalance());
                        break;
                    case 2:
                        System.out.print("Enter an amount to withdraw: ");
                        account.withDraw(input.nextDouble());
                        break;
                    case 3:
                        System.out.print("Enter an amount to deposit: ");
                        account.deposit(input.nextDouble());
                        break;
                    default:
                        stop = true;
                }
            }

        }

    }


}
"D:\java 12.0\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\lib\idea_rt.jar=56657:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\26601\Desktop\library_management_sys-master\untitled10\out\production\untitled10 Test
Enter the id: 2
2

Main menu
1: check balance
2: withdraw    
3: deposit     
4: exit        
Enter a choice: 1
The balance is 100.0

Main menu
1: check balance
2: withdraw    
3: deposit     
4: exit        
Enter a choice: 2
Enter an amount to withdraw: 10

Main menu
1: check balance
2: withdraw    
3: deposit     
4: exit        
Enter a choice: 1
The balance is 90.0

Main menu
1: check balance
2: withdraw    
3: deposit     
4: exit        
Enter a choice: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值