「atm界面java」atm操作界面

博主:adminadmin 2022-12-28 10:57:06 53

本篇文章给大家谈谈atm界面java,以及atm操作界面对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

atm机的java怎么写啊

package demo;

import java.io.*;

/*该类为实现客户信息及部分功能*/

class Account {

private String code =null; //信用卡号

private String name =null; //客户姓名

private String password=null; //客户密码

private double money =0.0; //卡里金额

/********************/

public Account(String code,String name,String password,double money)

{

this.code=code;

this.name=name;

this.password=password;

this.money=money;

}

protected String get_Code() {

return code;

}

protected String get_Name() {

return name;

}

protected String get_Password() {

return password;

}

public double get_Money() {

return money;

}

/*得到剩余的钱的数目*/

protected void set_Balance(double mon) {

money -= mon;

}

/*得到剩余的钱的数目*/

protected void set_Deposit(double mon) {

money += mon;

}

}

/**********实现具体取款机功能*********/

class ATM {

Account act;

// private String name;

// private String pwd;

public ATM() {

act=new Account("000000","Devil","123456",50000);

}

/***********欢迎界面***********/

protected void Welcome()

{

String str="---------------------------------";

System.out.print(str+"\n"+

"欢迎使用Angel模拟自动取款机程序.\n"+str+"\n");

System.out.print(" 1.取款."+"\n"+

" 2.存款."+"\n"+

" 3.查询信息."+"\n"+

" 4.密码设置."+"\n"+

" 5.退出系统."+"\n");

}

/**********登陆系统**********/

protected void Load_Sys() throws Exception

{

String card,pwd;

int counter=0;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

do {

System.out.println("请输入您的信用卡号:");

card=br.readLine();

System.out.println("请输入您的密码:");

pwd=br.readLine();

if(!isRight(card,pwd))

{

System.out.println("您的卡号或密码输入有误.");

counter++;

}

else

Welcome();

SysOpter();

}while(counter3);

Lock_Sys();

}

/**********系统操作**********/

protected void SysOpter() throws Exception

{

int num;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("请选择您要操作的项目(1-5):");

num=br.read(); //num为ASICC码转换的整数

switch(num) {

case 49: BetBalance(); break;

case 50: Deposit(); break;

case 51: Inqu_Info(); break;

case 52: Set_Password(); break;

case 53: Exit_Sys(); break;

}

System.exit(1);

}

/**********信息查询

* @throws Exception **********/

protected void Inqu_Info() throws Exception {

System.out.print("---------------------\n"+

act.get_Code()+"\n"+

act.get_Name()+"\n"+

act.get_Money()+"\n"+

"-----------------------");

Welcome();

SysOpter();

}

/**********取款**********/

public void BetBalance() throws Exception

{

String str=null,str1;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int count=0;//取款错误超过3次自动退出

do {

System.out.println("请输入您要取的数目:");

str=br.readLine();

str1=String.valueOf(act.get_Money());

System.out.println(str1);

if(Double.parseDouble(str)Double.parseDouble(str1)) {

count++;

System.out.println("超过已有的钱数,请重新输入您要取的数目:");

if(count=3){

System.out.println("超过已有的钱数,请重新输入您要取的数目:");

Exit_Sys();

}

}

else {

/*操作成功*/

act.set_Balance(Double.parseDouble(str));

System.out.println("取款成功,请收好您的钱.");

Welcome();

SysOpter();

}

}while(true);

}

/*******存款********/

public void Deposit() throws Exception{

String str=null;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

do {

System.out.println("请输入您要存的数目:");

str=br.readLine();

/*操作成功*/

act.set_Deposit(Double.parseDouble(str));

System.out.println("取款成功,请收好您的钱.");

Welcome();

SysOpter();

}while(true);

}

/**********判断卡内是否有钱**********/

protected boolean isBalance() {

if(act.get_Money()0) {

System.out.println("对不起,您的钱数不够或卡已透支.");

return false;

}

return true;

}

/********卡号密码是否正确******/

protected boolean isRight(String card,String pwd)

{

if(act.get_Code().equals(card) act.get_Password().equals(pwd))

return true;

else

return false;

}

/**********密码修改**********/

protected void Set_Password() throws Exception

{

String pwd=null;

int counter=0;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

do {

System.out.println("请输入旧密码:");

pwd=br.readLine();

if(act.get_Password().equals(pwd))

{

do {

System.out.println("请输入新密码:");

String pwd1=br.readLine();

System.out.println("请再次输入新密码:");

String pwd2=br.readLine();

if(!pwd1.equals(pwd2))

{

System.out.println("两次输入不一致,请再次输入.");

}

else

{

System.out.println("密码修改成功,请使用新密码.");

Welcome();

SysOpter();

}

}while(true);

}

}while(counter3);

}

/**********锁定机器**********/

protected void Lock_Sys() {

System.out.println("对不起,您的操作有误,卡已被没收.");

System.exit(1);

}

/**********结束系统**********/

protected void Exit_Sys() {

System.out.println("感谢您使用本系统,欢迎下次在来,再见!");

System.exit(1);

}

}

public class Text

{

public static void main(String[] args) throws Exception

{

ATM atm=new ATM();

atm.Load_Sys();

// atm.Exit_Sys();

}

}

卡号:00000 密码123456 默认50000金额。简单版本的存取款。

JAVA 模拟ATM柜员机模拟程序

/**

     要求:使用字符用户界面。当输入给定的卡号和密码(初始卡号和密码为123456)时,系统能登录ATM柜员机系统,用户可以按照以下规则进行:

    1、查询余额:初始余额为10000元

    2、ATM取款:每次取款金额为100的倍数,总额不超过5000元,支取金额不允许透支。

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

    4、修改密码:新密码长度不小于6位,不允许出现6位完全相同的情况,只有旧密码正确,新密码符合要求,且两次输入相同的情况下才可以成功修改密码。

    (卡号密码余额放到文件中)

 */

public class Test {

    private static int account;

    private static int password;

    private static int money;

    private static boolean isLogin;

    static{

        account = 123456;

        password = 123456;

        money = 10000;

        isLogin = false;

    }

    //存款

    public void cun(int cunKuan){

        if(cunKuan=0){

            this.money += cunKuan;

        }else{

            System.out.println("存款不能为负!");

        }

    }

    //取款

    public void qu(int quKuan){

        if(this.money - quKuan  0){

            System.out.println("余额不足!");

            return;

        }

        

        if(isValid(quKuan)){

            this.money -= quKuan;

        }else{

            System.out.println("取款不能为负,且应为100的倍数!");

        }

    }

    //判断是否为有效的金额

    private boolean isValid(int money){

        if(money = 0  money % 100 == 0){

            return true;

        }

        return false;

    }

    

    //登陆

    public void login(){

        System.out.println("请输入账号和密码【格式为:账号/密码】");

        String login = new Scanner(System.in).next();

        if(login.equalsIgnoreCase("123456/123456")){

            this.isLogin = true;

        }else{

            System.out.println("账号或者密码错误,请重新输入!");

            login();

        }

    }

    

    //主菜单

    public void show(){

        System.out.println("[1]存款");

        System.out.println("[2]取款");

        System.out.println("[3]退出");

        System.out.println("请输入:");

        int key = new Scanner(System.in).nextInt();

        switch (key) {

        case 1:

            cun(new Scanner(System.in).nextInt());

            break;

        case 2:

            qu(new Scanner(System.in).nextInt());

            break;

        case 3:

            System.exit(0);

        default:

            break;

        }

    }

    public static void main(String[] args) {

        Test t = new Test();

        t.login();

        if(t.isLogin){

            for(;;){

                t.show();

                System.out.println("您当前的余额为:" + t.money);

            }

        }

        

    }

}

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

代码如下

package BaiDdu;

import java.util.Scanner;

public class ATM {

/*1提示请输入密码然后直接进入下一步。密码6位限制(限制方法用 “最小大于100000最大小于999999”这样限制)

2.提示密码正确还是错误密码直接弄成“123456”错误返回上一步循环方法用for循环。

3.密码输入正确后进入下一步提示5个选项(1.余额查询“基础10000”2.取款  3存款4.退出)

4.进行取款或者存款之后要回到第三步重新选择(余额和取款存款相关联)

备注:用键盘输入的方法用scanner*/

private static int money=10000;//全局变量 余额 默认10000

public static void main(String args[])

{

for(;;){//for循环,有意思吗?

    System.out.println("请输入密码:");

Scanner input=new Scanner(System.in);

int pw=input.nextInt();

if ( Checkpw(pw)) {

System.out.println("密码正确。");

Next();

}

else  System.out.println("密码错误!");

}

}

public static boolean Checkpw(int pw)

{

if (pw==123456)return true;//固定密码就不需要限制位数了,反正不符合就错

else

return false;

}

public static void Next() {

do {

System.out.println("请选择你需要的功能:");

System.out.println("1.余额查询  2.取款  3.存款 4.退出");

int value = new Scanner(System.in).nextInt();

switch (value) {

case 1:// 查询余额

System.out.println("您的余额为 "+money+"元");

break;

case 2:// 取款

System.out.println("请输入取款金额:");

 

int getnum=new Scanner(System.in).nextInt();

if (getnum0) System.out.println("输入金额有误!");

else if(getnummoney)System.out.println("余额不足.");

else {money=money-getnum;System.out.println("取款成功,余额为"+money);}

break;

case 3:// 存款

System.out.println("请输入存款金额:");

 

int pushnum= new Scanner(System.in).nextInt();

if (pushnum0) System.out.println("输入金额有误!");

else {money=money+pushnum;System.out.println("存款成功,余额为"+money);}

break;

case 4:// 退出

System.out.println("谢谢使用!");

System.exit(0);

break;

 

default:

System.out.println("输入有误");

break;

}

 

}while(true);

}

}

2、运行效果

java用网络编程和图形用户界面实现atm机的存,取款,转账,查询,修改密码的操作。不需要存储信息

import javax.swing.JOptionPane;

public class Account

{

private String name;

private String account;

private String data;

private String ID;

private double balance;

public Account(String name,double balance,String data,String ID)

{

this.name = name;

this.balance = balance;

this.data=data;

this.ID=ID;

}

public String getaccount()

{

this.account=String.valueOf((int)(Math.random()*100000)+1);

return account;

}

public String getdata()

{

return data;

}

public String getID()

{

return ID;

}

public String getName()

{

return name;

}

public double getbalance()

{

return balance;

}

//查看账户余额

public double balance()

{

return balance;

}

//查看开户时间

public String data()

{

return data;

}

//存款操作

public boolean put(double value)

{

if (value0)

{

this.balance += value;

return true;

}

return false;

}

//取款操作

public double get(double value)

{

if (value0)

{

if (value=this.balance)

this.balance -= value;

else

{

value = this.balance;

this.balance = 0;

}

return value;

}

return 0;

}

public static void main(String args[]){

Account user=new Account("张三",2000,"2011/05/23","362329198906234225");

String str;

int b;

String s=JOptionPane.showInputDialog("您好,存款选择1,取款选择2,退出选择0");

int x=Integer.parseInt(s);

while(x!=0){

if(x==1)

{

str=JOptionPane.showInputDialog("输入您要存入的数额");

b=Integer.parseInt(str);

if( user.put(b)){

JOptionPane.showMessageDialog(null, "请放入钞票!");

JOptionPane.showMessageDialog(null,"开户账号为"+user.getaccount()+"\n"+user.getName()+"\n开户时间为"+user.data()+"\n您的余额为"+user.balance());

}

else

JOptionPane.showMessageDialog(null, "你所输入的存款数额有误!");

}

else{

str=JOptionPane.showInputDialog("输入您要取出的数额");

b=Integer.parseInt(str);

if(buser.balance())

{

JOptionPane.showMessageDialog(null, "余额不足");

}

else

{

JOptionPane.showMessageDialog(null, "请取出钞票!");

user.get(b);

JOptionPane.showMessageDialog(null,"开户账号为"+user.getaccount()+"\n"+user.getName()+"\n开户时间为"+user.data()+"\n您的余额为"+user.balance());

}

}

s=JOptionPane.showInputDialog("您好,存款选择1,取款选择2,退出选择0");

x=Integer.parseInt(s);

}

}

}

关于atm界面java和atm操作界面的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-12-28,除非注明,否则均为首码项目网原创文章,转载请注明出处。