public class Card {
普蘭店網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站,普蘭店網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為普蘭店上千多家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的普蘭店做網(wǎng)站的公司定做!
public String type; //卡的類型
public String cardCode; //卡號(hào)
public double money; //錢
/**
* 重寫toString()方法
*/
public String toString(){
return "卡的類型:"+type+"\t卡號(hào):"+cardCode+"\t余額:"+money;
}
}public class Person {
Card card;
/**
* 構(gòu)造方法,一般用來(lái)初始化信息
* 此方法是創(chuàng)建對(duì)象時(shí)自動(dòng)調(diào)用的
*
*/
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("余額不足:請(qǐng)存款!");
return 0;
}
}
/**
* 存款
* @param money
*/
public void setMoney(double money){
if(money=0){
System.out.println("不能為0!");
}else
card.money=card.money+money;
}
/**
* 這個(gè)方法是輸出客戶卡的信息
*/
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);
}
}
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;
}
}
}
}
import java.util.*;
public class ATM {
static int people=123456;
static int mima=123456;
static int yue=10000;
static Scanner in=null;
public ATM(int people,int mima){
this.mima=mima;
}
public static void main(String[] args) {
chongxindenglu();
int count=1;
while(count!=0){
System.out.println("1、查詢余額");
System.out.println("2、取款");
System.out.println("3、存款");
System.out.println("4、修改密碼");
System.out.println("5、重新登錄");
count=in.nextInt();
switch(count){
case 1: System.out.println(10000); System.out.println(); break;
case 2: quKuan(); break;
case 3: cunKuan(); break;
case 4: xiugai(); break;
case 5: chongxindenglu();
}
}
}
public static void quKuan(){
System.out.println("請(qǐng)輸入取款金額:");
int qukuanjine=in.nextInt();
if(qukuanjine5000){
System.out.println("取款金額不能大于5000"+"\n");
}else{
if(qukuanjine%100!=0){
System.out.println("取款金額必須為100的整數(shù)倍"+"\n");
}else{
yue=yue-qukuanjine;
System.out.println("您取出了"+qukuanjine+"元,您現(xiàn)在的余額為:"+yue+"元"+"\n");
}
}
}
public static void cunKuan(){
System.out.println("請(qǐng)輸入存款金額");
int cunkuanjine=in.nextInt();
if(cunkuanjine0){
System.out.println("存款金額不能小于0");
}else{
yue=yue+cunkuanjine;
System.out.println("您已成功存入:"+cunkuanjine+"元,您現(xiàn)在總余額為:"+yue+"元"+"\n");
}
}
public static void xiugai(){
System.out.println("請(qǐng)輸入您的密碼:");
int mima1=in.nextInt();
if(mima1==mima){
System.out.println("請(qǐng)輸入新密碼:");
mima=in.nextInt();
System.out.println("您的密碼已修改為:"+mima+"\n");
}else{
System.out.println("密碼輸入錯(cuò)誤:"+"\n");
}
}
public static void chongxindenglu(){
in=new Scanner(System.in);
System.out.println("請(qǐng)輸入登錄帳號(hào):");
int denglupeople=in.nextInt();
System.out.println("請(qǐng)輸入登錄密碼:");
int denglumima=in.nextInt();
if(denglupeople==people denglumima==mima)
System.out.println("帳號(hào)登錄成功"+"\n");
else
System.out.println("密碼輸入錯(cuò)誤,登錄失敗"+"\n");
}
}
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("請(qǐng)選擇您的操作 1 取錢 2 存錢 3 轉(zhuǎn)賬 4 查詢 5 退出 ");
int n = scanner.nextInt();
if(n==1){//取錢
System.out.println("請(qǐng)輸入金額");
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("請(qǐng)輸入金額");
int save = scanner.nextInt();
if(save=0){
money+=save;
}
}else if(n==3){//轉(zhuǎn)賬
System.out.println("請(qǐng)輸入目標(biāo)賬戶");
String target = scanner.next();
if(target.equals(targetName)){
System.out.println("請(qǐng)輸入金額");
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("沒有該項(xiàng)服務(wù)");
}
}
}else{
cnt--;
System.out.println("輸入錯(cuò)誤,您還有"+cnt+"次機(jī)會(huì)");
username=null;
password=null;
if(cnt=0){
System.out.println("對(duì)不起,您的賬號(hào)被凍結(jié),請(qǐng)到最近的營(yíng)業(yè)廳解除凍結(jié)");
System.exit(0);
}
}
}else{
System.out.println("請(qǐng)輸入您的賬號(hào)");
username = scanner.next();
System.out.println("請(qǐng)輸入您的密碼");
password = scanner.next();
}
}
}
}