扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
public static void main(String[] args) {
创新互联建站坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站制作、成都做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的番禺网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
String realPwd = "111111";
Integer errorCount = 0;
Integer account;
Scanner sc = new Scanner(System.in);
while(true){
System.out.print("请输入密码:");
String pwd = 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(account1000 || account0){
System.out.println("取款金额最低0元,最高1000元");
}else if(account%100!=0){
System.out.println("只有100的纸币");
}else{
System.out.println("取款金额"+account+"元");
System.out.println("交易完成,请取卡");
break;
}
}
break;
}
}
}
import javax.swing.JOptionPane;
public class Account
{
private String name;
private String account;
private String data;
private String ID;
private double balance;
public Account(String name,double balance,String data,String ID)
{
this.name = name;
this.balance = balance;
this.data=data;
this.ID=ID;
}
public String getaccount()
{
this.account=String.valueOf((int)(Math.random()*100000)+1);
return account;
}
public String getdata()
{
return data;
}
public String getID()
{
return ID;
}
public String getName()
{
return name;
}
public double getbalance()
{
return balance;
}
//查看账户余额
public double balance()
{
return balance;
}
//查看开户时间
public String data()
{
return data;
}
//存款操作
public boolean put(double value)
{
if (value0)
{
this.balance += value;
return true;
}
return false;
}
//取款操作
public double get(double value)
{
if (value0)
{
if (value=this.balance)
this.balance -= value;
else
{
value = this.balance;
this.balance = 0;
}
return value;
}
return 0;
}
public static void main(String args[]){
Account user=new Account("张三",2000,"2011/05/23","362329198906234225");
String str;
int b;
String s=JOptionPane.showInputDialog("您好,存款选择1,取款选择2,退出选择0");
int x=Integer.parseInt(s);
while(x!=0){
if(x==1)
{
str=JOptionPane.showInputDialog("输入您要存入的数额");
b=Integer.parseInt(str);
if( user.put(b)){
JOptionPane.showMessageDialog(null, "请放入钞票!");
JOptionPane.showMessageDialog(null,"开户账号为"+user.getaccount()+"\n"+user.getName()+"\n开户时间为"+user.data()+"\n您的余额为"+user.balance());
}
else
JOptionPane.showMessageDialog(null, "你所输入的存款数额有误!");
}
else{
str=JOptionPane.showInputDialog("输入您要取出的数额");
b=Integer.parseInt(str);
if(buser.balance())
{
JOptionPane.showMessageDialog(null, "余额不足");
}
else
{
JOptionPane.showMessageDialog(null, "请取出钞票!");
user.get(b);
JOptionPane.showMessageDialog(null,"开户账号为"+user.getaccount()+"\n"+user.getName()+"\n开户时间为"+user.data()+"\n您的余额为"+user.balance());
}
}
s=JOptionPane.showInputDialog("您好,存款选择1,取款选择2,退出选择0");
x=Integer.parseInt(s);
}
}
}
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);
}
}
/** * @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(counter3); Lock_Sys(); } 回复获取全部
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;
}
}
}
}
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();
}
}
}
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流