我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

ATM取款机代码java atm取款机全称

Java编程自动取款机步骤

Java编写的模拟ATM取款机程序/*** @version 1.0

岢岚ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

* @author Devil_Angel

* 该程序的功能为实现模拟银行ATM自动取款机提款,查询等功能.

*

*/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;

}

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

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");

}

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

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

SysOpter();

}while(counter3);

Lock_Sys();

}

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

protected void SysOpter() throws Exception

{

int num;

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

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

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

switch(num) {

case 49: BetBalance(); break;

case 50: Inqu_Info(); break;

case 51: Set_Password(); break;

case 52: Exit_Sys(); break;

}

System.exit(1);

}

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

protected void Inqu_Info() {

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

act.get_Code()+"\n"+

act.get_Name()+"\n"+

act.get_Money()+"\n"+

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

}

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

public void BetBalance() throws Exception

{

String str=null,str1;

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

do {

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

str=br.readLine();

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

if(str.compareTo(str1)0) {

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

}

else {

/*操作成功*/

// act.set_Balance(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.Welcome();

atm.Load_Sys();

// atm.Exit_Sys();

}

} //模拟ATM取款机工作流程 import java.util.Scanner;public class Atm {

public Atm() {

}

public static void main(String[] args) {

// TODO code application logic here

Scanner sc = new Scanner(System.in);

int password = 0;

int count = 0;

int choice = 0;

int type = 0;

int input = 0;

int acount = 1000;

boolean exit = false;

int flag = 0;

do{

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

password = sc.nextInt();

count++;

}while(password != 12345 count3);

if(password == 12345){

//密码正确继续后面的操作。

do{

System.out.println("请选择您的操作,1.查询 2.取款");

choice = sc.nextInt();

switch(choice){

case 1:

do{

System.out.println("请选择帐户类型:1. 美元 2. 人民币");

type = sc.nextInt();

if(type == 1){

System.out.println("You have $"+acount+"!");

}else if(type == 2){

System.out.println("您有"+acount+"圆!");

}else{

System.out.println("类型选择错误,请重新选择!");

}

System.out.println("1.继续 2.离开");

flag = sc.nextInt();

if(flag == 1){

exit = false;

}else{

exit = true;

}

}while(type!=1 type!=2);

break;

case 2: do{

System.out.println("请选择帐户类型:1. 美元 2. 人民币");

if(type == 1){

System.out.println("Please input number of your money!");

input = sc.nextInt();

if(input acount){

System.out.println("You have not enough money!");

}else{

System.out.println("You take care of your money!");

}

System.out.println("1.continue 2.exit");

flag = sc.nextInt();

if(flag == 1){

exit = false;

}else{

exit = true;

}

}else if(type == 2){

System.out.println("请输入您要取的金额!");

input = sc.nextInt();

if(input acount){

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

}else{

System.out.println("请妥善保管您的钱!");

acount = acount - input;

}

System.out.println("1.继续 2.离开");

flag = sc.nextInt();

if(flag == 1){

exit = false;

}else{

exit = true;

}

}else{

System.out.println("类型选择错误,请重新选择!");

}

}while(type!=1 type!=2);

break;

default: System.out.println("类型选择错误,请重新选择!");

}

}while(choice!=1 choice!=2 || exit == false);

}else{

//密码错误,退出。

System.out.println("三次密码错误,吞卡!");

}

}

}

Java编程实现程序用于模拟ATM取款机。

package demo;

import java.util.Scanner;

public class Test3 {

public static void main(String[] args) {

Scanner scanner =new Scanner(System.in);

int cnt=3;

String username = null;

String password = null;

double money = 1000;

String targetName = "admin33";

double targetMoney = 1000;

while(true){

if(username!=nullpassword!=null){

if("admin".equals(username) "123".equals(password)){

System.out.println("欢迎光临");

while(true){

System.out.println("请选择您的操作 1 取钱 2 存钱 3 转账 4 查询 5 退出 ");

int n = scanner.nextInt();

if(n==1){//取钱

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

int getter = scanner.nextInt();

if(getter=0){

if(getter=5000){

if(getter=money){

money-=getter;

}else{

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

}

}else{

System.out.println("单笔只能取5000及以下");

}

}else{

System.out.println("银行不到给");

}

}else if(n==2){//存钱

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

int save = scanner.nextInt();

if(save=0){

money+=save;

}

}else if(n==3){//转账

System.out.println("请输入目标账户");

String target = scanner.next();

if(target.equals(targetName)){

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

int getter = scanner.nextInt();

if(getter=0){

if(getter=5000){

if(getter=money){

money-=getter;

targetMoney+=getter;

}else{

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

}

}else{

System.out.println("单笔只能取5000及以下");

}

}else{

System.out.println("银行不到给");

}

}

}else if(n==4){//查询

System.out.println(money);

}else if(n==5){//退出

System.exit(0);

}else{

System.out.println("没有该项服务");

}

}

}else{

cnt--;

System.out.println("输入错误,您还有"+cnt+"次机会");

username=null;

password=null;

if(cnt=0){

System.out.println("对不起,您的账号被冻结,请到最近的营业厅解除冻结");

System.exit(0);

}

}

}else{

System.out.println("请输入您的账号");

username = scanner.next();

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

password = scanner.next();

}

}

}

}

使用Java语言中(类和对象)编写: ATM自动存取款机的程序?

很简单的例子,我把代码贴出来吧

import java.util.Scanner;

public class ATM {

/**

* @param args

*/

public static void main(String[] args) {

Scanner in = null;

int result;

double drawMoney;

double depositMoney;

Account account = new Account();

while (true) {

System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆(ABC)中国农业银行ATM自动存取款机☆☆☆☆☆☆☆☆☆☆☆☆☆");

System.out.println("\n\t\t\t\t1.存款业务");

System.out.println("\n\t\t\t\t2.取款业务");

System.out.println("\n\t\t\t\t3.查询余额");

System.out.println("\n\t\t\t\t4.退出ATM系统");

System.out.println("\n☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆中国农业银行欢迎您的使用☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");

in = new Scanner(System.in);

switch (in.nextInt()) {

case 1:

System.out.println("请输入您的存款数额!");

depositMoney = in.nextDouble();

if(depositMoney 0)

System.out.println("您的输入无效,请重新输入!");

result = account.deposit(depositMoney);

if(result == 0){

System.out.println("存款业务完成,是否显示余额?Y/N");

if("Y".equalsIgnoreCase(in.next())){

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

}else {

break;

}

}else {

System.out.println("无法完成交易!");

break;

}

break;

case 2:

System.out.println("请输入您的取款数额!");

drawMoney = in.nextDouble();

if (drawMoney 0) {

System.out.println("您的输入无效,请重新输入!");

}

result = account.withDraw(drawMoney);

if (result == 0) {

System.out.println("存款业务完成,是否显示余额?Y/N");

if("Y".equalsIgnoreCase(in.next())){

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

}else {

break;

}

} else {

System.out.println("无法完成交易!");

break;

}

case 3:

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

break;

case 4:

break;

default:

break;

}

}

}

}

public class Account {

private double currentMoney;//当前余额

public double getCurrentMoney() {

return currentMoney;

}

public void setCurrentMoney(double currentMoney) {

if (currentMoney 0) {

this.currentMoney = currentMoney;

}

}

/**

* 取款业务

* @param drawMoney

* @return 0代表成功,1代表失败

*/

public int withDraw(double drawMoney) {

if (currentMoney 0 drawMoney = currentMoney) {

currentMoney -= drawMoney;

} else {

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

return 1;

}

return 0;

}

/**

* 存款业务

* @param depositMoney

* @return 0代表成功,1代表失败

*/

public int deposit(double depositMoney) {

if (depositMoney 0) {

currentMoney += depositMoney;

return 0;

}else {

System.out.println("您提交的存款为负数,无法完成存款交易");

return -1;

}

}

/**

* 查询余额业务

* @return

*/

public double checkCurrent() {

return currentMoney;

}

}

java编写的模拟ATM取款机程序

我现写的: import java.util.Scanner;public class ATM {

private static String theName = "admin";

private static String thePassword = "123456";

private static int balance = 10000;

public static void getBalance(){

System.out.println("当前余额:" + balance);

}

public static void drawMoney(Scanner sc){

int money = 0;

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

money = sc.nextInt();

String type = "";

if (balance 0) {

if (balance = money) {

if (money = 5000) {

balance = balance - money;

type = "请在30秒内提取现金...\n剩余余额:"+balance;

} else if (money = 0) {

type = "金额错误";

} else {

type = "超出最大限制金额";

}

} else {

type = "超出最大余额";

}

} else {

type = "余额不足";

}

System.out.println(type);

}

public static void bankMoney(Scanner sc){

int money = 0;

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

money = sc.nextInt();

String type = "";

if (money 0) {

balance = balance + money;

type = "存储成功,现有余额:" + balance;

} else {

type = "存储金额不能为负";

}

System.out.println(type);

}

public static void updatePass(Scanner sc){

String oldPass = "";

String newPass1 = "";

String newPass2 = "";

while(true){

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

oldPass = sc.next();

if (oldPass.equals(thePassword)) {

break;

} else {

System.out.println("密码错误,请重新输入");

}

}

while(true){

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

newPass1 = sc.next();

System.out.println("再次输入");

newPass2 = sc.next();

if (newPass1.equals(newPass2)) {

if (!isSame(newPass1)) {

thePassword = newPass1;

System.out.println("修改成功");

break;

} else {

System.out.println("所有字符不能相同,重新输入");

}

} else {

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

}

}

}

public static boolean isSame(String string){

boolean bool = false;

for (int i = 0; i string.length() - 1; i++) {

char char1 = string.charAt(i);

for (int j = i + 1; j string.length(); j++) {

char char2 = string.charAt(j);

if (char1 == char2) {

bool = true;

break;

}

}

}

return bool;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(true){

String name = "";

String password = "";

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

name = sc.next();

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

password = sc.next();

if (name.equals(theName) password.equals(thePassword)) {

break;

} else {

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

}

}

while(true){

int operate = 0;

System.out.println("请选择你要进行的操作:\n1、查询 2、取款 3、存款 4、修改密码 0、退出");

operate = sc.nextInt();

if (0 == operate) {

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

break;

} else if (1 == operate) {

getBalance();

} else if (2 == operate) {

drawMoney(sc);

} else if (3 == operate) {

bankMoney(sc);

} else if (4 == operate) {

updatePass(sc);

}

}

}

}

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金额。简单版本的存取款。


文章名称:ATM取款机代码java atm取款机全称
当前链接:http://shouzuofang.com/article/hgjgjc.html

其他资讯