真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

自動取款機代碼java,自動取款機全稱

Java編程實現(xiàn)程序用于模擬ATM取款機。

package demo;

目前創(chuàng)新互聯(lián)建站已為上1000家的企業(yè)提供了網(wǎng)站建設、域名、雅安服務器托管網(wǎng)站托管運營、企業(yè)網(wǎng)站設計、遵義網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

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("對不起,您的賬號被凍結,請到最近的營業(yè)廳解除凍結");

System.exit(0);

}

}

}else{

System.out.println("請輸入您的賬號");

username = scanner.next();

System.out.println("請輸入您的密碼");

password = scanner.next();

}

}

}

}

java atm機代碼

package arraylist;

import java.util.Scanner;

public class AtmDemo

{

public static void main(String[] args)

{

// TODO Auto-generated method stub

Scanner sc = new Scanner(System.in);

Boolean flag = true;

int times = 0;

while(flag){

times++;

if(times == 4){

System.out.println("密碼錯誤,請取卡");

break;

}

System.out.println("請輸入你的密碼");

String password = sc.next();

if(password.equals("111111")){

Boolean moneyflag = true;

while(moneyflag){

System.out.println("請輸入金額");

int number = sc.nextInt();

if(number = 0 number = 1000 number % 100 == 0){

System.out.println("用戶取了" + number + "元。交易完成");

moneyflag = false;

}else{

System.out.println("請重新輸入金額");

}

}

break;

}else{

continue;

}

}

}

}

急急急~~求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;

/**

* 構造方法,一般用來初始化信息

* 此方法是創(chuàng)建對象時自動調用的

*

*/

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 * 該程序的功能為實現(xiàn)模擬銀行ATM自動取款機提款,查詢等功能. */ import Java.io.*; /*該類為實現(xiàn)客戶信息及部分功能*/ 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; } /*得到剩余的錢的數(shù)目*/ protected void set_Balance(double mon) { money -= mon; } } /**********實現(xiàn)具體取款機功能*********/ 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.退出系統(tǒng)." "\n"); } /**********登陸系統(tǒng)**********/ 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(); } 回復獲取全部

如何用Java編寫模擬ATM取款機的程序

import java.io.IOException;

/**

* ATM機類

*

* 查看余額

*

* 取款

*

* 存款

*

* 退出系統(tǒng)

*

*

*

*/

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);// 返回實際讀取的字節(jié)數(shù)

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("您已經(jīng)成功退出系統(tǒng),謝謝你的使用");

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);// 返回實際讀取的字節(jié)數(shù)

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 {

// 輸入的字符不是數(shù)值

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(",現(xiàn)在余額¥:" + yue);

}

}

/**

* 存款

*

* @throws IOException

*/

private void deposit() throws IOException {

byte[] buffer = new byte[512];

System.out.print("請輸入您要存入的金額:¥");

int count2 = System.in.read(buffer);// 返回實際讀取的字節(jié)數(shù)

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 {

// 輸入的字符不是數(shù)值

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(",現(xiàn)在余額¥:" + yue);

}

}

}

java編寫的模擬ATM取款機程序

我現(xiàn)寫的: 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èi)提取現(xiàn)金...\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 = "存儲成功,現(xiàn)有余額:" + 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);

}

}

}

}


本文題目:自動取款機代碼java,自動取款機全稱
瀏覽路徑:http://weahome.cn/article/hspcii.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部