/**
成都創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),玉環(huán)企業(yè)網(wǎng)站建設(shè),玉環(huán)品牌網(wǎng)站建設(shè),網(wǎng)站定制,玉環(huán)網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷(xiāo),網(wǎng)絡(luò)優(yōu)化,玉環(huán)網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專(zhuān)業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
要求:使用字符用戶界面。當(dāng)輸入給定的卡號(hào)和密碼(初始卡號(hào)和密碼為123456)時(shí),系統(tǒng)能登錄ATM柜員機(jī)系統(tǒng),用戶可以按照以下規(guī)則進(jìn)行:
1、查詢余額:初始余額為10000元
2、ATM取款:每次取款金額為100的倍數(shù),總額不超過(guò)5000元,支取金額不允許透支。
3、ATM存款:不能出現(xiàn)負(fù)存款。
4、修改密碼:新密碼長(zhǎng)度不小于6位,不允許出現(xiàn)6位完全相同的情況,只有舊密碼正確,新密碼符合要求,且兩次輸入相同的情況下才可以成功修改密碼。
(卡號(hào)密碼余額放到文件中)
*/
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("存款不能為負(fù)!");
}
}
//取款
public?void?qu(int?quKuan){
if(this.money?-?quKuan??0){
System.out.println("余額不足!");
return;
}
if(isValid(quKuan)){
this.money?-=?quKuan;
}else{
System.out.println("取款不能為負(fù),且應(yīng)為100的倍數(shù)!");
}
}
//判斷是否為有效的金額
private?boolean?isValid(int?money){
if(money?=?0??money?%?100?==?0){
return?true;
}
return?false;
}
//登陸
public?void?login(){
System.out.println("請(qǐng)輸入賬號(hào)和密碼【格式為:賬號(hào)/密碼】");
String?login?=?new?Scanner(System.in).next();
if(login.equalsIgnoreCase("123456/123456")){
this.isLogin?=?true;
}else{
System.out.println("賬號(hào)或者密碼錯(cuò)誤,請(qǐng)重新輸入!");
login();
}
}
//主菜單
public?void?show(){
System.out.println("[1]存款");
System.out.println("[2]取款");
System.out.println("[3]退出");
System.out.println("請(qǐng)輸入:");
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("您當(dāng)前的余額為:"?+?t.money);
}
}
}
}
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("密碼錯(cuò)誤,請(qǐng)取卡");
break;
}
System.out.println("請(qǐng)輸入你的密碼");
String password = sc.next();
if(password.equals("111111")){
Boolean moneyflag = true;
while(moneyflag){
System.out.println("請(qǐng)輸入金額");
int number = sc.nextInt();
if(number = 0 number = 1000 number % 100 == 0){
System.out.println("用戶取了" + number + "元。交易完成");
moneyflag = false;
}else{
System.out.println("請(qǐng)重新輸入金額");
}
}
break;
}else{
continue;
}
}
}
}
/** * @author admin * 該程序的功能為實(shí)現(xiàn)模擬銀行ATM自動(dòng)取款機(jī)提款,查詢等功能. */ import Java.io.*; /*該類(lèi)為實(shí)現(xiàn)客戶信息及部分功能*/ class Account { private String code =null; //信用卡號(hào) 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; } /*得到剩余的錢(qián)的數(shù)目*/ protected void set_Balance(double mon) { money -= mon; } } /**********實(shí)現(xiàn)具體取款機(jī)功能*********/ 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模擬自動(dòng)取款機(jī)程序.\n" str "\n"); System.out.print(" 1.取款." "\n" " 2.查詢信息." "\n" " 3.密碼設(shè)置." "\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("請(qǐng)輸入您的信用卡號(hào):"); card=br.readLine(); System.out.println("請(qǐng)輸入您的密碼:"); pwd=br.readLine(); if(!isRight(card,pwd)) { System.out.println("您的卡號(hào)或密碼輸入有誤."); counter ; } else SysOpter(); }while(counter3); Lock_Sys(); } 回復(fù)獲取全部
public static void main(String[] args) {
Scanner s, money;
int pass = 1111;
int tempass;
int choose = 0;
mkar: for (int i = 0; i 3; i++) {
s = new Scanner(System.in);
money = new Scanner(System.in);
tempass = s.nextInt();
if (tempass == pass) {
for (;;) {
System.out.println("請(qǐng)輸入1到9的數(shù)字選擇你要取款的");
choose = money.nextInt();
switch (choose) {
case 1:
System.out.println("取款100");
break;
case 2:
System.out.println("取款200");
break;
case 3:
System.out.println("取款300");
break;
case 4:
System.out.println("取款400");
break;
case 5:
System.out.println("取款500");
break;
case 6:
System.out.println("取款600");
break;
case 7:
System.out.println("取款700");
break;
case 8:
System.out.println("取款800");
break;
case 9:
System.out.println("取款900");
break;
case 0:System.out.println("操作成功退出");
break mkar;
}
}
} else {
System.out.println("密碼錯(cuò)誤");
}
}
}
看下是不是你的要求,也可以自己改下
class ATM{
private double balance;
public double getBalance(){
return balance;
}
public void setBalance(double balance){
this.balance=balance;
}
//根據(jù)用戶ID查詢余額
public double getBalance(String NO){
//加載數(shù)據(jù)庫(kù)驅(qū)動(dòng);
//建立數(shù)據(jù)庫(kù)連接;
double balance=//執(zhí)行查詢語(yǔ)句并返回結(jié)果集;
return balance;
}
}
public class ATMTest{
public void main(String[] args){
ATM atm=new ATM();
double balance=atm.getBalance("123");
System.out.println(balance);
}
}