java ATM机 数据库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java ATM机 数据库相关的知识,希望对你有一定的参考价值。

请尽量用简单的代码写,我是初学者,太复杂了老师就知道不是我们写的,还有就是连接数据库不要用ACESS,用SQL
模拟银行ATM自动取款机的操作。当用户插入有效的银行卡时,可以对用户的银行卡种类做出判断(借记卡还是信用卡)。提示用户输入密码,如果用户连续密码输入错误次数达到3次,则吞卡,并给用户一个友好的提示信息。如果用户可以进入系统,则用户可以实现取款、查询、存款、转账等业务。待用户的每次交易结束时,系统提示是否打印详单。用户交易结束,系统提示退卡操作,让用户可以退出银行卡。如果用户忘记退出银行卡,则系统在交易结束后120秒以后,自动吞卡。用户交易过程中,每操作时间不能超过90秒,否则系统吞卡。操作时间,可以显示在界面上。
所有交易中,用户存款,或者取款,转账等交易数据需要存储在数据库中。以方便用户未来的查询和系统的管理与维护。

你说你叫什么名字??我是唐善成!我给你解决!!追问

薛明政????

追答

擦!!受不鸟你了!!这都发现我了!!

追问

我草,就是TMD还好意思弄自己的QQ号做网名。。。。

参考技术A #include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
class AccountItem

private:
string m_Anumber;// 账号
string m_Password;//密码
string m_Name;//姓名
double m_Balance;//存款余额
string m_Adress;
string m_ID;
string m_TEL;
string m_classif;
string m_Currency;
int year;
int month;
int day;
double touzhi;
int nianxian;
public:
string GetID()

return m_ID;

AccountItem(AccountItem &a)

m_Anumber=a.m_Anumber;
m_Password=a.m_Password;
m_Name=a.m_Name;
m_Balance=a.m_Balance;
m_Currency=a.m_Currency;
m_classif=a.m_classif;
m_TEL=a.m_TEL;
m_ID=a.m_ID;
m_Adress=a.m_Adress;

AccountItem &operator=(AccountItem &a)

m_Anumber=a.m_Anumber;
m_Password=a.m_Password;
m_Name=a.m_Name;
m_Balance=a.m_Balance;
m_Currency=a.m_Currency;
m_classif=a.m_classif;
m_TEL=a.m_TEL;
m_ID=a.m_ID;
m_Adress=a.m_Adress;
return *this;

void SetAccountItem(string number,string password,
string name,double balance,string Currency,
string classif,string TEL,string ID,string Adress);
AccountItem();
AccountItem(string number,string password,
string name,double balance,string Currency,
string classif,string TEL,string ID,string Adress);
void Display();//显示数据
void write(ofstream &out);//写入账目数据
void read(ifstream& cin);//读入账目数据
int CheckNumber(string ID);//检查账号
string GetNumber();//获取账号
string GetPassword();
void UpdatePassword(string password);//获取密码
void DeductBalance();
void StoreBalance();//修改存款余额
double GetBalance();
int lookyear();
string GetName();
int IsNull();
void print();
void showbalance();
virtual void storepay()

cout<<"存款"<<endl;


;
void AccountItem::SetAccountItem(string number,string password,string name,
double balance,string Currency,string classif,
string TEL,string ID,string Adress)

m_Anumber=number;
m_Password=password;
m_Name=name;
m_Balance=balance;
m_Currency=Currency;
m_classif=classif;
m_TEL=TEL;
m_ID=ID;
m_Adress=Adress;

void AccountItem::UpdatePassword(string password)

m_Password=password;

int AccountItem::lookyear()

int y;
y=year+nianxian;
return y;

void AccountItem::print()

cout<<lookyear()<<"年"<<month<<"月"<<day<<"日"<<endl;

void AccountItem::StoreBalance()

int n;
int y;
int m;
int d;
int a;
double pay,money;
do
cout<<"*****************存款种类*******************************************\t"<<endl;
cout<<"\t\t0:退出\t"<<endl;
cout<<"\t\t1:定期存款\t"<<endl;
cout<<endl;
cout<<"\t\t2:信用卡存款\t"<<endl;
cout<<"\t\t3:活期存款\t"<<endl;
cout<<"**********************************************************************\t"<<endl;
cin>>n;
switch(n)

case 0:
break;
case 3:
cout<<"请输入存款金额:"<<endl;
cin>>pay;
if(m_Balance>0)

m_Balance=m_Balance+pay;


break;
case 1:

cout<<"请输入存款金额:"<<endl;
cin>>pay;
cout<<"请输入存款 年限:";
cin>>a;
nianxian=a;
cout<<"请输入当日存款的年月日:";
cin>>y;
year=y;
cin>>m;
month=m;
cin>>d;
day=d;
m_Balance=m_Balance+pay;
break;
case 2:
//money=m_Balance;
while( m_Balance<0)

cout<<"先交清透支!"<<money<<endl;
cin>>money;
m_Balance=m_Balance+money;


cout<<"请输入存款金额:"<<endl;
cin>>pay;
m_Balance=m_Balance+pay;
break;

while(n!=0);


int AccountItem::CheckNumber(string ID)

if(m_ID==ID)

return 1;

else

return 0;


string AccountItem::GetNumber()

return m_Anumber;

string AccountItem::GetPassword()

return m_Password;

void AccountItem::showbalance()

cout<<"超额支出度:"<<touzhi<<endl;

void AccountItem::DeductBalance()

int n;
double pay;
int y;
int m;
int d;
int money;
do

cout<<"***********************取款种类:*********************************\t"<<endl;
//cout<<"取款种类:"<<endl;
cout<<"0:退出"<<endl;
cout<<"1:定期取款\t"<<endl;
cout<<"2:信用卡取款\t"<<endl;
cout<<"3:活期取款\t"<<endl;
cout<<"*********************************************************************\t"<<endl;
cin>>n;
switch(n)

case 0:
break;
case 3:
if(m_Balance>0)

cout<<"请输入取款金额:"<<endl;
cin>>pay;
m_Balance=m_Balance-pay;
cout<<"正在出钞中......"<<endl;

else

touzhi=0.00;

break;
case 1:
cout<<"请输入你当前取款的年月日:";
cin>>y;
cin>>m;
cin>>d;
money=lookyear();
if(y>money)

if(m_Balance>0)

cout<<"请输入取款金额:"<<endl;
cin>>pay;
m_Balance=m_Balance-pay;
cout<<"正在出钞中......"<<endl;

else

touzhi=0.00;


else if(y==money)

if(m>month)

if(m_Balance>0)

cout<<"请输入取款金额:"<<endl;
cin>>pay;
m_Balance=m_Balance-pay;
cout<<"正在出钞中......"<<endl;

else

touzhi=0.00;


else if(m==month)

if(d>day)

if(m_Balance>0)

cout<<"请输入取款金额:"<<endl;
cin>>pay;
m_Balance=m_Balance-pay;
cout<<"正在出钞中......"<<endl;

else

touzhi=0.00;


else

cout<<"未到期不能取!"<<endl;


else

cout<<"未到期不能取!"<<endl;


else

cout<<"未到期不能取!";

break;
case 2:
if(m_Balance>=-10000)

cout<<"请输入取款金额:"<<endl;
cin>>pay;
m_Balance=m_Balance-pay;
if(m_Balance<0)

touzhi=m_Balance;

else

touzhi=0.00;

cout<<"正在出钞中......"<<endl;
break;

break;

while(n!=0);


double AccountItem::GetBalance()

return m_Balance;

string AccountItem::GetName()

return m_Name;

int AccountItem::IsNull()

if(m_Anumber=="")
return 1;
return 0;

void AccountItem::read(ifstream& cin)

cin>>m_ID;
cin>>m_Name;
cin>>m_Adress;
cin>>m_TEL;
cin>>m_classif;
cin>>m_Currency;
cin>>m_Balance;
cin>>m_Anumber;
cin>>m_Password;

void AccountItem::write(ofstream &cout)


cout<<m_ID<<endl;
cout<<m_Name<<endl;
cout<<m_Adress<<endl;
cout<<m_TEL<<endl;
cout<<m_classif<<endl;
cout<<m_Currency<<endl;
cout<<m_Balance<<endl;
cout<<m_Anumber<<endl;
cout<<m_Password<<endl;

AccountItem::AccountItem()

m_Anumber="";
m_Password="";
m_Name="";
m_Balance=0;
m_Currency="";
m_classif="";
m_TEL="";
m_ID="";
m_Adress="";

AccountItem::AccountItem(string number,string password,
string name,double balance,
string Currency,string classif,
string TEL,string ID,string Adress)

m_Anumber=number;
m_Password=password;
m_Name=name;
m_Balance=balance;
m_Currency=Currency;
m_classif=classif;
m_TEL=TEL;
m_ID=ID;
m_Adress=Adress;

void AccountItem::Display()

cout<<"身份证号:";
cout<<m_ID<<endl;
cout<<"姓名:";
cout<<m_Name<<endl;
cout<<"家庭住址:";
cout<<m_Adress<<endl;
cout<<"电话号码:";
cout<<m_TEL<<endl;
cout<<"账户类型:";
cout<<m_classif<<endl;
cout<<"货币种类:";
cout<<m_Currency<<endl;
cout<<"预存款:";
cout<<m_Balance<<endl;
cout<<"帐号:";
cout<<m_Anumber<<endl;
cout<<"密码:";
cout<<m_Password<<endl;

class Accountbook

private:
AccountItem b[100];
int m_AccountCount;
public:
void SetAccountbook();
Accountbook();
void LoadAccountbook();
void StoreAccountbook();
void checkAccountbok();
AccountItem FindItem(string number);
bool UpdateItem(AccountItem Item);
;
void Accountbook::checkAccountbok()

LoadAccountbook();
string id;
int flag=0;
cout<<"请输入身份证号:";
cin>>id;
for(int i=0;i<m_AccountCount;i++)

if(id==b[i].GetID())

flag=1;
b[i].Display();


if(flag==0)

cout<<"此用户没有账户!"<<endl;

return;

void Accountbook::SetAccountbook()

string AccountNo;
string AccountPassword;
string ItemName;
double Balance;
string Currency;
string classif;
string TEL;
string ID;
string Adress;
ofstream Output("accountbook.txt");
cout<<"请输入身份证号:";
cin>>ID;
cout<<"请输入姓名:";
cin>>ItemName;
cout<<"请输入家庭住址:";
cin>>Adress;
cout<<"请输入电话号码:";
cin>>TEL;
cout<<"请输入账户类型:";
cin>>classif;
cout<<"请输入货币种类:";
cin>>Currency;
cout<<"请输入预存款:";
cin>>Balance;
cout<<"请输入帐号:";
cin>>AccountNo;
cout<<"请输入密码:";
cin>>AccountPassword;
b[m_AccountCount].SetAccountItem(AccountNo,AccountPassword,ItemName,
Balance, Currency,classif,TEL,ID,Adress);
m_AccountCount++;
for(int j=0;j<m_AccountCount;j++)

b[j].write(Output);


Accountbook::Accountbook()

m_AccountCount=0;

void Accountbook::LoadAccountbook( )

ifstream Input("accountbook.txt");
int j=0;
while(Input)

b[j].read(Input);
j++;

Input.close();
m_AccountCount=j;
return;

AccountItem Accountbook::FindItem(string number)

int i;
bool Found=false;
for(i=0;i<m_AccountCount;i++)

if(b[i].GetNumber()==number)

Found=true;
break;


if(Found==true)

return b[i];

else

return AccountItem();


bool Accountbook::UpdateItem(AccountItem Item)

string no=Item.GetNumber();
int i;
bool flag=false;
for(i=0;i<m_AccountCount;i++)

if(b[i].GetNumber()==no)

flag=true;
break;


if(flag=true)

b[i]=Item;

return flag;

void Accountbook::StoreAccountbook()

ofstream Output("accountbook.txt");
int k;
for(k=0;k<m_AccountCount;k++)

b[k].write(Output);

Output.close();
return;

class Massage

private:
Accountbook MyAccountbook;
AccountItem FindItem;
public:
Massage();
void MakeMassage();
;
Massage::Massage()

ifstream Input("accountbook.txt");

void Massage::MakeMassage()

int n;
string AccountNo;
string AccountPassword;
string id;

string ItemName;
//double Balance;
string TransactionCode;
cout<<"\t\t中国建设银行为您服务!\t"<<endl;
cout<<endl;
do

cout<<"*********************************ATM取款机****************************\t"<<endl;
cout<<"\t\t0:退出\t"<<endl;
cout<<endl;
cout<<"\t\t1:创建账户\t"<<endl;
cout<<endl;
cout<<"\t\t2:用户登录\t"<<endl;
cout<<endl;
cout<<"\t\t3:查询您的所账户\t"<<endl;
cout<<"************************************************************************\t"<<endl;
cin>>n;
switch(n)

case 3:
MyAccountbook.checkAccountbok();
break;
case 1:
MyAccountbook.SetAccountbook();
break;
case 2:

MyAccountbook.LoadAccountbook( );
cout<<"请输入帐号:";
cin>>AccountNo;
FindItem=MyAccountbook.FindItem(AccountNo);
if(FindItem.IsNull())

cout<<"此用户不存在!"<<endl;
return;

cout<<"请输入密码:";
cin>>AccountPassword;
if(FindItem.GetPassword()!=AccountPassword)

cout<<"密码错误!"<<endl;
return;

int m;
do

cout<<"*********************************************************************\t"<<endl;
cout<<"\t\t0:退出\t"<<endl;
cout<<endl;
cout<<"\t\t1:取款\t"<<endl;
cout<<endl;
cout<<"\t\t2:修改密码\t"<<endl;
cout<<endl;
cout<<"\t\t3:显示余额\t"<<endl;
cout<<endl;
cout<<"\t\t4:存款\t"<<endl;
cout<<endl;
cout<<"\t\t5:查看存储年限( 只针对定期存款用户)\t"<<endl;
cout<<endl;
cout<<"\t\t6:查看透支额度( 只针对信用卡用户)\t"<<endl;
cout<<endl;
cout<<"**********************************************************************\t"<<endl;
cin>>m;
switch(m)

case 5:
FindItem.print();
break;
case 6:
FindItem.showbalance();
break;
case 4:

FindItem.StoreBalance();
MyAccountbook.UpdateItem(FindItem);
MyAccountbook.StoreAccountbook();
break;
case 1:
FindItem.DeductBalance();
MyAccountbook.UpdateItem(FindItem);
MyAccountbook.StoreAccountbook();
break;
case 2:
cout<<"请输入原密码:"<<endl;
cin>>AccountPassword;
if(FindItem.GetPassword()==AccountPassword)

cout<<"请输入新密码:"<<endl;
cin>>AccountPassword;
FindItem.UpdatePassword(AccountPassword);
cout<<"请确认新密码:"<<endl;
cin>>AccountPassword;
if(FindItem.GetPassword()==AccountPassword)

cout<<"修改成功!"<<endl;
MyAccountbook.UpdateItem(FindItem);
MyAccountbook.StoreAccountbook();


break;
case 3:
double money;
money=FindItem.GetBalance();
cout<<money<<endl;
break;

while(m!=0);
case 0:
break;

while(n!=0);
return;

int main()

Massage desk;
desk.MakeMassage();
return 0;
追问

我咋看你这不像是java写的啊!!像是C

本回答被提问者和网友采纳
参考技术B ... 参考技术C 这个太高级。不会。 参考技术D 用oracle数据库?追问

最好是MY sql。或者是JDBD-ODBC桥

追答

我倒,你这是一个小项目了,现在没那么多时间来写这种,我相信有这项目的也不一定会拿出来

追问

呃。。这是我们学校的这学期的一个小作业,我在学校,不在公司!!

追答

那就是很简单的逻辑咯,这个自己去做一个强多了,以前我也是各种求,现在想想真是蠢了,在学校多学点,以后就轻松点了

Java ATM模拟系统报告

设计内容:

本系统采用JAVA语言编写测试完成,基本上在字符界面下模拟了ATM系统的相关实现。

本系统主要模拟银行ATM机系统功能,主要有查阅、取款、存款、添加用户、删除用户等功能。

技术说明:

项目目录下必须有一个已经录入的用户文件,名为ATMUsers (无后缀名,压缩包内已有一份),否则将报错。

当输入用户的卡号和密码时,系统能登录ATM柜员机系统,用户可以按照以下规则进行:

查询余额。

ATM取款:每次取款金额不得大于100,总额不得超过余额。

ATM存款:不能出现负存款。

当输入用户名000000与密码000000时,能登录ATM柜员机系统的管理员账户,管理员可以按照以下规则进行:

列出用户:列出ATM系统上的所有用户。

添加用户:卡号必须为10位,新密码长度必须为6位,只有卡号与密码都符合要求的情况下才可以添加用户。

删除用户:输入卡号以删除卡号对应用户的记录,删除前必须键入Y以确认。

源代码:

import java.util.*;

import java.io.*;


public class ATM {
    static int number;
    static int usernum = 0;
    static boolean isAdmin = false;
    public static Scanner kbd = new Scanner(System.in);
 

    public static void readLength() throws IOException {
        BufferedReader file = null;

        try  {
            file =  new BufferedReader(new InputStreamReader(new FileInputStream("ATMUsers")));
            String line = null;
            int count = 0;
            while ((line = file.readLine()) != null) count++;
            number = count;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (file != null) {
                try {
                    file.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }


    public static void readUsers(String[][] users) throws IOException {
        BufferedReader file = null;

        try  {
            file =  new BufferedReader(new InputStreamReader(new FileInputStream("ATMUsers")));
            String line = null;
            int count = 0;
            while ((line = file.readLine()) != null) {
                String data = line;
                String[] strArray = data.split(" ");
                users[0][count] = strArray[0];
                users[1][count] = strArray[1];
                users[2][count] = strArray[2];
                count++;
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (file != null) {
                try {
                    file.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }


    public static String checkID(String acctNum, String pwd, String[][] users) {
        String result = "错误!";
        for(int i = 0;i < number;i++) {
            if (acctNum.equals("000000") && pwd.equals("000000")) {
                isAdmin = true;
                return "0";
            }
            if (acctNum.equals(users[0][i]) && pwd.equals(users[1][i])) {
                result = users[2][i];
                usernum = i;
            }
        }
        return result;
    }


    public static int menu() {
        int menuChoice;
 

        do
        {
            System.out.print("\n请选择想要执行的操作:\n"
                    + "**********************"
                    + "\n* 一、余额\t二、存款 *\n"
                    + "*                    *"
                    + "\n* 三、取款\t四、退出 *\n"
                    + "**********************\n");
            menuChoice = kbd.nextInt();
            if (menuChoice < 1 || menuChoice > 4){
                System.out.println("错误!");
            }
        }while (menuChoice < 1 || menuChoice > 4);
        return menuChoice;
    }


    public static int adminMenu() {
        int menuChoice;


        do
        {
            System.out.print("\n请选择想要执行的操作:\n"
                    + "******************************"
                    + "\n* 一、读取用户\t二、添加用户 *\n"
                    + "*                            *"
                    + "\n* 三、删除用户\t四、退出管理 *\n"
                    + "******************************\n");
            menuChoice = kbd.nextInt();
            if (menuChoice < 1 || menuChoice > 4){
                System.out.println("错误!");
            }
        }while (menuChoice < 1 || menuChoice > 4);
        return menuChoice;
    }


    public static void displayBalance(double x) {
        System.out.printf("\n您的余额为 $%.2f\n", x);
    }


    public static double deposit(double x, double y, String[][] users) {
        double depositAmt = y, currentBal = x;
        double newBalance = depositAmt + currentBal;
        System.out.printf("您现在的余额为:$%.2f\n",  newBalance);
        users[2][usernum] = "" + newBalance;
        return newBalance;
    }
 

    public static double withdraw(double x, double y, String[][] users) {
        double withdrawAmt = y, currentBal = x, newBalance;
        newBalance = currentBal - withdrawAmt;
        users[2][usernum] = "" + newBalance;
        System.out.printf("您现在的余额为:$%.2f\n",newBalance);
        return newBalance;
    }


    public static String[][] addUser(String[][] users) throws IOException {
        System.out.print("\n请输入您想要添加的用户卡号:");
        String data1 = kbd.next();
        if(data1.length() != 10) {
            System.out.print("卡号长度不符!");
            return users;
        }
        for(int i = 0;i < number;i++) {
            if(data1 == users[0][i])
                System.out.print("已有同名用户!");
            return users;
        }
        System.out.print("\n请输入密码:");
        String data2 = kbd.next();
        if(data2.length() != 6) {
            System.out.print("密码长度不符!");
        }
        System.out.print("\n请输入初始资金:");
        String data3 = kbd.next();
        String[][] newusers = new String[3][number + 1];
        for(int i = 0; i < number;i++) {
            newusers[0][i] = users[0][i];
            newusers[1][i] = users[1][i];
            newusers[2][i] = users[2][i];
        }
        newusers[0][number] = data1;
        newusers[1][number] = data2;
        newusers[2][number] = data3;
        FileWriter fileWriter = new FileWriter("ATMUsers",true);
        BufferedWriter bufferWriter = new BufferedWriter(fileWriter);
        bufferWriter.newLine();
        bufferWriter.write(data1);
        bufferWriter.write(‘ ‘);
        bufferWriter.write(data2);
        bufferWriter.write(‘ ‘);
        bufferWriter.write(data3);
        bufferWriter.close();
        number++;
        System.out.print("\n添加成功!");
        return newusers;
    }


    public static void deleteUser(String[][] users) throws IOException {
        System.out.print("\n请输入您想要删除的用户卡号:");
        String todelete = kbd.next();
        int i;
        boolean exist = false;
        for(i = 0;i < number;i++) {
            if(todelete.equals(users[0][i])) {
                exist = true;
                break;
            }
        }
        if(exist != true) {
            System.out.print("\n错误:用户不存在!");
            return;
        }
        System.out.print("\n确认要删除该用户吗?(键入Y以确认)");
        String check = kbd.next();
        if(!check.equals("y") && !check.equals("Y")) {
            return;
        }
        int j;
        for(j = i;j < number - 1;j++) {
            users[0][j] = users[0][j + 1];
            users[1][j] = users[1][j + 1];
            users[2][j] = users[2][j + 1];
        }
        number--;
        System.out.print("\n删除成功!");
    }


    public static void remakeFile(String[][] users) throws IOException {
        File file =  new File("ATMUsers");
        file.delete();
        File newfile =  new File("ATMUsers");
        newfile.createNewFile();
        FileWriter fileWriter = new FileWriter(newfile.getName(),true);
        BufferedWriter bufferWriter = new BufferedWriter(fileWriter);
        for(int i = 0;i < number;i++) {
            if(i != 0) bufferWriter.newLine();
            bufferWriter.write(users[0][i]);
            bufferWriter.write(‘ ‘);
            bufferWriter.write(users[1][i]);
            bufferWriter.write(‘ ‘);
            bufferWriter.write(users[2][i]);
        }
        bufferWriter.close();
    }


    public static void main(String[] args) throws IOException {
        String accNum, pass, origBal = "错误!";
        int count = 0, menuOption = 0;
        double depositAmt = 0, withdrawAmt = 0, currentBal = 0;

 
        readLength();
        String[][] users = new String[3][number];
        readUsers(users);
        do{
            System.out.print("请输入账户名:");
            accNum = kbd.next();
            System.out.print("请输入密码:");
            pass = kbd.next();
            origBal = checkID(accNum, pass,users);
            count++;
            if (count >= 3 && origBal.equals("错误!")){
                System.out.print("尝试次数已达上限!");
                System.exit(0);
            }
            if (!(origBal.equals("错误!"))){
                if(isAdmin == false) System.out.println("\n您的余额为 $" + Float.parseFloat(users[2][usernum]));
                if(isAdmin == true) System.out.println("\n您正以管理员身份登录。");
            }
            else
                System.out.println(origBal);
        }while(origBal.equals("错误!"));
        currentBal=Double.parseDouble(origBal);
        while (menuOption != 4 && isAdmin == true) {
            menuOption = adminMenu();
            switch (menuOption) {
                case 1:
                    for (int i = 0; i < number; i++){
                        System.out.println("用户" + (i + 1) + ": " + users[0][i]);
                    }
                    continue;
                case 2:
                    users = addUser(users);
                    continue;
                case 3:
                    deleteUser(users);
                    continue;
                case 4:
                    System.out.print("\n正在退出……");
                    remakeFile(users);
                    System.exit(0);
                    break;
            }
        }
            while (menuOption != 4 && isAdmin == false) {
            menuOption= menu();
            switch (menuOption)
            {
                case 1:
                    displayBalance(currentBal);
                    continue;
                case 2:
                    System.out.print("\n请输入您想要存储的数额:$ ");
                    depositAmt = kbd.nextDouble();
                    if(depositAmt < 0.0) {
                        System.out.print("\n不得进行负存款!");
                        continue;
                    }
                    currentBal=deposit(depositAmt, currentBal,users);
                    continue;
                case 3:
                    System.out.print("\n请输入您想要提取的数额:$ ");
                    withdrawAmt = kbd.nextDouble();
                    while(withdrawAmt > 100.0 || withdrawAmt > currentBal) {
                        System.out.print("错误:一次取款太多!" + "\n请输入较小的数额:$");
                        withdrawAmt = kbd.nextDouble();
                    }
                    currentBal = withdraw(currentBal, withdrawAmt,users);
                    continue;
                case 4:
                    System.out.print("\n正在退出……");
                    remakeFile(users);
                    System.exit(0);
                    break;
            }
        }
    }
}

 

以上是关于java ATM机 数据库的主要内容,如果未能解决你的问题,请参考以下文章

JAVA编写模拟ATM机进行帐户余额查询 实现存款和取款业务(使用带参数的方法)

模拟ATM机银行系统

ATM

JAVA - ATM机程序

用java做一个简易的ATM机具体流程在下面

Java ATM机