导航:首页 > 源码编译 > java怎么编译银行atm取钱

java怎么编译银行atm取钱

发布时间:2022-04-13 08:27:42

㈠ 使用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;
}
}

㈡ ATM机取钱题的java做法

publicstaticvoidmain(String[]args){

StringrealPwd="111111";

IntegererrorCount=0;

Integeraccount;

Scannersc= newScanner(System.in);

while(true){

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

Stringpwd=sc.next();

if(!pwd.equals(realPwd)){

errorCount++;

System.out.println("第"+errorCount+"次输入密码不正确");

if(errorCount>=3){

System.out.println("密码错误,请取卡");

break;

}

}else{

while(true){

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

account=sc.nextInt();

if(account>1000||account<0){

System.out.println("取款金额最低0元,最高1000元");

}elseif(account%100!=0){

System.out.println("只有100的纸币");

}else{

System.out.println("取款金额"+account+"元");

System.out.println("交易完成,请取卡");

break;

}

}

break;

}

}

}

㈢ 急急急~~求JAVA中用方法写出一个银行ATM取款机的代码怎么写!!

public class Card {
public String type; //卡的类型
public String cardCode; //卡号
public double money; //钱

/**
* 重写toString()方法
*/
public String toString(){
return "卡的类型:"+type+"\t卡号:"+cardCode+"\t余额:"+money;
}
}public class Person {
Card card;

/**
* 构造方法,一般用来初始化信息
* 此方法是创建对象时自动调用的
*
*/
public Person(){
card=new Card();
card.type="招商银行";
card.money=1000D;
}

/**
*
* @param money 你要取的钱
* @return 返回的是取到的钱
*/
public double getMoney(double money){
if( (card.money-money) >=0){
card.money=card.money-money;//从卡中减去要取的钱,并重新改变卡中的余额
return money;
}else{
System.out.println("余额不足:请存款!");
return 0;
}
}

/**
* 存款
* @param money
*/
public void setMoney(double money){
if(money<=0){
System.out.println("不能为0!");
}else
card.money=card.money+money;
}

/**
* 这个方法是输出客户卡的信息
*/
public void print(){
System.out.println(card);
}
}public class Text {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Person p=new Person();
p.card.cardCode="111100022222";
p.setMoney(1000);
double money=p.getMoney(2000);

System.out.println(p.card);
}

}

㈣ 用java编写的ATM机源代码

/** * @author admin * 该程序的功能为实现模拟银行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(counter<3); Lock_Sys(); } 回复获取全部

㈤ ATM取款机系统用JAVA怎么做/

这里有个模拟
用户:blucastle ,密码: 123

import java.util.Scanner;

public class ATM1 {
Scanner sc = new Scanner(System.in);
private String name = "blucastle";

private double password = 123;

private double money = 500;

public void aloha(){
System.out.println("***********************");
System.out.println("* *");
System.out.println("* 欢迎使用ATM *");
System.out.println("* *");
System.out.println("* 制作人:blucastle*");
System.out.println("* *");
System.out.println("* *");
System.out.println("************************");
System.out.println("请输入用户名:");
String s = sc.next();
if(s.equals("blucastle")) {
System.out.println("请输入密码:");
int ss = sc.nextInt();
if(ss == 123) {
land();
}else{
System.out.println("密码错误,系统退出");
System.exit(0);
}
}else{
System.out.println("用户名错误,系统退出");
System.exit(0);
}

}
//登陆页面
public void land(){

System.out.println("请选择操作界面:1取款,2存款,3查询,4转账,5退出");
int a = sc.nextInt();// 请加入此句
switch(a){
case 1 : // 去掉‘’ 因为a 为int型。
get();
break;
case 2 :
set();
break;
case 3 :
query();
break;
case 4 :
divert();
break;
case 5 :
SetOut();
break;
}
}

//取款
public void get(){
System.out.println("请输入取款金额:");
int a = sc.nextInt();
if(a>money){
System.out.println("余额不足!");
}else{
money-=a;
System.out.println("当前余额为:"+money);
land();
}

}
//存款
public void set(){
System.out.println("请输入存款金额:");
int a = sc.nextInt();
money+=a;
System.out.println("当前余额为:"+money);
land();

}
//查询
public void query(){
System.out.println("当前余额为:"+money);
land();

}
//转账
public void divert(){
System.out.println("该功能站未开放!");
land();
}
//退出
public void SetOut(){
System.exit(0);
}

public static void main(String[] args) {
ATM1 atm = new ATM1();
atm.aloha();

}

}

㈥ 用Java编写银行账户存取款业务,急求!!

publicclassAccount{

protectedStringaccId;
protectedStringname;
protecteddoublemoney;

publicAccount(StringaccId,Stringname){
this(accId,name,0);
}

publicAccount(StringaccId,Stringname,doublemoney){
this.accId=accId;
this.name=name;
this.money=money;
}

publicvoidsaveMoney(doublemoney){
if(money<=0){
System.out.println("存款金额必须大于0");
}
this.money+=money;
System.out.println("存款成功");
}

publicdoublegetMoney(doublemoney){
if(money<=0){
System.out.println("取款金额必须大于0");
return0;
}
if(this.money<=money){
System.out.println("余额不足,无法取款");
return0;
}
this.money-=money;
System.out.println("取款成功");
returnmoney;
}

publicdoublegetBalance(){
returnthis.money;
}

protecteddoublegetOverdraft(){
return0;
}

//实现了equals方法,list比较时才能正确
@Override
publicbooleanequals(Objectobj){
if(obj==null){
returnfalse;
}
if(this==obj){
returntrue;
}
if(objinstanceofAccount){
returnthis.accId.equals(((Account)obj).accId);
}
returnfalse;
}

@Override
publicStringtoString(){
return"账户="+accId+",名字="+name+",余额="+money;
}

}
publicclassBank{

//Account实现了equals方法,list查找时才能正确
privateList<Account>usersAccounts;

publicBank(){
usersAccounts=newArrayList<Account>();
}

publicvoidaddAccount(Accountaccount){
if(usersAccounts.contains(account)){
System.out.println("添加失败,不能添加同样的账户");
return;
}
usersAccounts.add(account);
}

publicbooleandelAccount(Accountaccount){
returnusersAccounts.remove(account);
}

publicbooleandelAccount(StringaccId){
returndelAccount(newAccount(accId,null));
}

publicbooleanexistAccount(Accountaccount){
returnusersAccounts.contains(account);
}

publicbooleanexistAccount(StringaccId){
returnexistAccount(newAccount(accId,null));
}

publicAccountgetAccount(StringaccId){
returnusersAccounts.get(usersAccounts.indexOf(newAccount(accId,null)));
}

publicdoublegetAllMoney(){
//不考虑是否溢出,只是把所有用户余额相加
doubleresult=0;
for(Accountaccount:usersAccounts){
result+=account.getBalance();
}
returnresult;
}

publicdoublegetAllOverdraft(){
//不考虑是否溢出
doubleresult=0;
for(Accountaccount:usersAccounts){
result+=account.getOverdraft();
}
returnresult;
}

publicintgetAccountNum(){
returnusersAccounts.size();
}

publicintgetCreditAccountNum(){
intnum=0;
for(Accountaccount:usersAccounts){
//instanceof性能没有简单的方法快。
if(){
num++;
}
}
returnnum;
}

publicintgetSavingAccountNum(){
intnum=0;
for(Accountaccount:usersAccounts){
if(){
num++;
}
}
returnnum;
}

publicList<Account>getAllAccount(){
returnusersAccounts;
}
}
{

privatedoubleoverdraft;

publicCreditAccount(StringaccId,Stringname){
super(accId,name);
this.overdraft=1000;
}

publicCreditAccount(StringaccId,Stringname,doublemoney){
this(accId,name,money,1000);
}

publicCreditAccount(StringaccId,Stringname,doublemoney,doubleoverdraft){
super(accId,name,money);
this.overdraft=overdraft;
}

@Override
publicdoublegetMoney(doublemoney){
if(money<=0){
System.out.println("取款金额必须大于0");
return0;
}
if(this.money+overdraft<=money){
System.out.println("余额不足,无法取款");
return0;
}
this.money-=money;
System.out.println("取款成功");
returnmoney;
}

@Override
publicdoublegetOverdraft(){
returnoverdraft;
}

@Override
publicStringtoString(){
return"账户="+accId+",名字="+name+",余额="+money+",透支="+overdraft;
}
}
{

publicSavingAccount(StringaccId,Stringname){
super(accId,name);
}

publicSavingAccount(StringaccId,Stringname,doublemoney){
super(accId,name,money);
}

@Override
publicdoublegetMoney(doublemoney){
returnsuper.getMoney(money);
}

@Override
publicdoublegetOverdraft(){
returnsuper.getOverdraft();
}

}
publicclassTest{

privatestaticBankbank=newBank();
publicstaticvoidmain(String[]args){
Test.genAccount();
//开户
Accounta1=newCreditAccount("1","1",200,2000);
Accounta2=newSavingAccount("2","2",300);
Accounta3=newSavingAccount("3","3",400);
Accounta4=newCreditAccount("4","4",500,2000);
Accounta5=newCreditAccount("4","5",600,2000);//帐号4重
bank.addAccount(a1);
bank.addAccount(a2);
bank.addAccount(a3);
bank.addAccount(a4);
bank.addAccount(a5);
showNowAccount();
//销户
bank.delAccount("1");
bank.delAccount("2");
showNowAccount();
//存款
if(bank.existAccount("3")){
Accountacc=bank.getAccount("3");
acc.saveMoney(100);
}
showNowAccount();
//取款
if(bank.existAccount("3")){
Accountacc=bank.getAccount("3");
System.out.println("余额="+acc.getBalance());
acc.getMoney(100);
System.out.println("余额="+acc.getBalance());
acc.getMoney(1000);
System.out.println("余额="+acc.getBalance());
}
if(bank.existAccount("4")){
Accountacc=bank.getAccount("4");
System.out.println("余额="+acc.getBalance());
acc.getMoney(100);
System.out.println("余额="+acc.getBalance());
acc.getMoney(1000);
System.out.println("余额="+acc.getBalance());
acc.getMoney(10000);
System.out.println("余额="+acc.getBalance());
}
System.out.println(bank.getAccountNum());
System.out.println(bank.getAllMoney());
System.out.println(bank.getAllOverdraft());
System.out.println(bank.getCreditAccountNum());
System.out.println(bank.getSavingAccountNum());
}

publicstaticvoidgenAccount(){
Strings="100000000000000";
Accounta=null;
for(inti=1;i<11;i++){
if((i&2)==0){
a=newCreditAccount(s+String.valueOf(i),"账户"+String.valueOf(i));
}else{
a=newSavingAccount(s+String.valueOf(i),"账户"+String.valueOf(i));
}
bank.addAccount(a);
}
}

(){
for(Accountaccount:bank.getAllAccount()){
System.out.println(account);
}
}
}

// 面向对象,看多写多了就会了,简单的随便写的,有错误先不用太纠结。

㈦ 如何用Java编写模拟ATM取款机的程序

import java.io.IOException;

/**
* ATM机类
*
* 查看余额
*
* 取款
*
* 存款
*
* 退出系统
*
*
*
*/

public class ATM {
static double yue = 1200.00;

public static void main(String[] arg) {
ATM localTest1 = new ATM();
localTest1.ATM_Operate();
}

/**
* ATM机的操作
*/
private void ATM_Operate() {
System.out.println("欢迎使用中国工商银行ATM取款机");
System.out.println("1、查看余额 2、取款");
System.out.println("3、存款 0、退出");
System.out.print("请输入您需要的服务:");
byte[] buffer = new byte[512];
try {
int count = System.in.read(buffer);// 返回实际读取的字节数
System.out.print("您输入的是:");
for (int i = 0; i < count; i++) {
System.out.print("" + (char) buffer[i]);
}
if ((char) buffer[0] == '1') {
// 查看余额
System.out.println("您的余额是:¥" + yue + "元");
System.out.println();
ATM_Operate();
} else if ((char) buffer[0] == '2') {
// 取款
withdrawal();
System.out.println();
ATM_Operate();
} else if ((char) buffer[0] == '3') {
// 存款
deposit();
System.out.println();
ATM_Operate();
} else if ((char) buffer[0] == '0') {
// 退出
System.out.println("您已经成功退出系统,谢谢你的使用");
System.exit(0);
} else {
System.out.println("输入不合法,请重新输入");
System.out.println();
ATM_Operate();
}

} catch (IOException e) {
e.printStackTrace();
}
}

/**
* 取款
*
* @throws IOException
*/
private void withdrawal() throws IOException {
byte[] buffer = new byte[512];

System.out.print("请输入您要取出的金额:¥");
int count2 = System.in.read(buffer);// 返回实际读取的字节数
System.out.print("您输入的金额是:");
for (int i = 0; i < count2 - 1; i++) {
System.out.print("" + (char) buffer[i]);
}
System.out.println();
// 字符0 ~ 9对应ASCII值48 ~ 57
boolean flag = false;
for (int i = 0; i < count2 - 1; i++) {
if ((char) buffer[i] > 47 && (char) buffer[i] < 58) {
if (i == count2 - 2) {
flag = true;
}
} else {
// 输入的字符不是数值
System.out.println("输入不合法,请重新输入");
withdrawal();
break;
}
}
System.out.println();
if (flag) {
System.out.print("您已成功取出¥:");
String num = "";
for (int i = 0; i < count2 - 1; i++) {
System.out.print("" + (char) buffer[i]);
num += (char) buffer[i];
}
yue -= Double.valueOf(num);
System.out.print(",现在余额¥:" + yue);

}
}

/**
* 存款
*
* @throws IOException
*/
private void deposit() throws IOException {
byte[] buffer = new byte[512];

System.out.print("请输入您要存入的金额:¥");
int count2 = System.in.read(buffer);// 返回实际读取的字节数
System.out.print("您输入的金额是:");
for (int i = 0; i < count2 - 1; i++) {
System.out.print("" + (char) buffer[i]);
}
System.out.println();
// 字符0 ~ 9对应ASCII值48 ~ 57
boolean flag = false;
for (int i = 0; i < count2 - 1; i++) {
if ((char) buffer[i] > 47 && (char) buffer[i] < 58) {
if (i == count2 - 2) {
flag = true;
}
} else {
// 输入的字符不是数值
System.out.println("输入不合法,请重新输入");
withdrawal();
break;
}
}
System.out.println();
if (flag) {
System.out.print("您已成功存入¥:");
String num = "";
for (int i = 0; i < count2 - 1; i++) {
System.out.print("" + (char) buffer[i]);
num += (char) buffer[i];
}
yue += Double.valueOf(num);
System.out.print(",现在余额¥:" + yue);

}
}
}

阅读全文

与java怎么编译银行atm取钱相关的资料

热点内容
汽油机压缩是什么 浏览:279
如何获得网站源码 浏览:822
搜索本机加密软件 浏览:209
三星迷你日记加密 浏览:818
优加密试卷五年级上册数学 浏览:932
社区购物app源码 浏览:123
程序员去北京完整视频 浏览:272
linuxscan 浏览:902
查看linux默认shell 浏览:151
百鸡问题java 浏览:714
通信信号调制识别原理与算法源码 浏览:721
e72手机安装什么app 浏览:177
程序员cv岗 浏览:257
ps下载解压后怎么找安装包 浏览:120
运动手环软件如何扫码下载安卓 浏览:468
程序员前期报道 浏览:155
游戏主文件夹是什么意思 浏览:800
极光电商app是什么软件 浏览:70
php调用html5 浏览:501
修改pdf安卓 浏览:478