简易ATM机(代码如下):

/*
* 功能:简易银行系统
*/
package day8;

import java.util.Scanner;

/**
*
* @FengYan Huang Administrator
* 下午1:07:20
*/
public class test8_1 {
static int count=0;
static int n=-1;
static boolean flag=false;
static String[] user=new String[10];
static int[] identity={62220000,62220001,62220001,62220002,62220003,62220004,62220005,62220006,62220007,62220008,62220009};
static int[] password=new int[10];
static int[] balance=new int[10];
static Scanner scan=new Scanner(System.in);
public static void main(String[] args) {
fun();
}
public static void fun(){
System.out.println("***欢迎使用ATM机***");
System.out.println("***请选择服务类型***");
System.out.println("***开户***");
System.out.println("***登录***");
System.out.println("***退出***");
String str=scan.next();
if(str.equals("开户")){
register();
}else if(str.equals("登录")){
login();
}else if(str.equals("退出")){
exit();
}else{
System.out.println("很抱歉,无法识别您的操作,请重新选择!!!");
fun();
}
}
public static void login(){

System.out.println("请输入您的卡号:");
int id=scan.nextInt();
for (int i = 0; i < identity.length; i++) {
if(id==identity[i]){
System.out.println("请输入您的密码:");
int ps=scan.nextInt();

if(id==identity[i]&&ps!=password[i]){
System.out.println("温馨提示:");
count++;
System.out.println("您已经输错了"+count+"次密码");
System.out.println("请返回重新操作!");
if(count==3){
System.out.println("您今日的密码输入次数已达上限,卡片已经被吞");
System.out.println("您是否已经忘记了密码???");
System.out.println("请联系本行取回卡片");
fun();
}
login();
}

if(id==identity[i]&&ps==password[i]){
n=i;
System.out.println("***登录成功***");
System.out.println("***欢迎您***"+user[i]);
System.out.println("***请选择服务项目***");
fun1(user,identity,password,balance);

}

}else{
flag=true;
}
}
if(flag=true){
System.out.println("没找到您的卡号!");
System.out.println("请重新操作");
flag=false;
login();
}

}
public static void register(){
System.out.println("***欢迎注册本行银行卡***");
System.out.println("***请输入您的姓名***");
String name=scan.next();
System.out.println("***请输入您的密码***");
int ps=scan.nextInt();
System.out.println("***请确认输入您的密码***");
int ps1=scan.nextInt();
if(ps==ps1){
for (int i = 0; i < user.length; i++) {
if(user[i]==null){
user[i]=name;
password[i]=ps;
System.out.println("***注册成功***");
System.out.println("***您的账户名是:"+user[i]);
System.out.println("***请牢记您的卡号:"+identity[i]);
System.out.println("***请牢记您的密码:"+password[i]);
fun();
}else{
flag=true;
}
}
if(flag=true){
flag=false;
System.out.println("***非常抱歉***");
System.out.println("***本行注册用户已达上限***");
System.out.println("***本行注册用户已达上限***");
fun();
}

}else{
System.out.println("注册失败!!!您两次输入的密码不一样");
fun();
}
}
public static void exit(){
System.out.println("***谢谢您的使用***");
System.out.println("***欢迎再次光临***");
System.out.println("***如果您有好的建议,请联系本行(95555)***");
System.exit(0);
}
public static void fun1(String[] user,int[]identity,int[]password,int[]balance){
System.out.println("***改密***");
System.out.println("***查询***");
System.out.println("***存款***");
System.out.println("***取款***");
System.out.println("***转账***");
System.out.println("***退出***");
String str=scan.next();
if(str.equals("改密")){
changePassword(user,identity,password,balance);
}else if(str.equals("查询")){
insert(user,identity,password,balance);
}else if(str.equals("存款")){
deposit(user,identity,password,balance);
}else if(str.equals("取款")){
withdraw(user,identity,password,balance);
}else if(str.equals("转账")){
transfer(user,identity,password,balance);
}else if(str.equals("退出")){
exit();
}else{
System.out.println("您的操作有误,请重新选择:");
fun1(user,identity,password,balance);
}
}
public static void changePassword(String[] user,int[]identity,int[]password,int[]balance){
System.out.println("***"+user[n]+"***");
System.out.println("***欢迎使用改密系统***");
System.out.println("***请输入新密码:***");
int ps=scan.nextInt();
System.out.println("***请确认新密码:***");
int ps1=scan.nextInt();
if(ps==ps1){
System.out.println("您的密码已经修改成功!");
password[n]=ps;
System.out.println("请牢记您的密码:"+ps);
System.out.println("***系统自动返回ing***");
fun1(user,identity,password,balance);
}else{
System.out.println("两次输入密码不一样!");
System.out.println("请重新操作!");
changePassword(user,identity,password,balance);
}
}
public static void insert(String[] user,int[]identity,int[]password,int[]balance){
System.out.println("***"+user[n]+"***");
System.out.println("***欢迎使用查询系统***");
System.out.println("***您的账户余额为:***");
System.out.println(balance[n]+"元");
System.out.println("***系统自动返回ing***");
fun1(user,identity,password,balance);
}
public static void deposit(String[] user,int[]identity,int[]password,int[]balance){
System.out.println("***"+user[n]+"***");
System.out.println("***欢迎使用存款系统***");
System.out.println("***请输入存款金额***");
int depositmoney=scan.nextInt();
System.out.println("***请放入百元大钞***");
if(depositmoney%100==0){
System.out.println("您要存入的金额是:"+depositmoney+"元");
System.out.println("***系统处理ing***");
balance[n]+=depositmoney;
System.out.println("存款成功!!!");
System.out.println("您的账户余额为:"+balance[n]+"元");
System.out.println("***系统自动返回ing***");
fun1(user,identity,password,balance);
}else{
System.out.println("存款失败!!!");
System.out.println("您放入纸币有疑问,请重新操作");
deposit(user,identity,password,balance);
}
}
public static void withdraw(String[] user,int[]identity,int[]password,int[]balance){
System.out.println("***"+user[n]+"***");
System.out.println("***欢迎使用取款系统***");
System.out.println("***请输入取款金额(为100元的整数倍)***");
int withdrawmoney=scan.nextInt();
System.out.println("***系统处理ing***");
if(balance[n]>withdrawmoney&&withdrawmoney%100==0){
balance[n]-=withdrawmoney;
System.out.println("***正在为您取款ing***");
System.out.println("***请取走您的钞票***");
System.out.println("***您的账户余额为:"+balance[n]+"元***");
System.out.println("***取款成功***");
System.out.println("***系统自动返回ing***");
fun1(user,identity,password,balance);
}else{
System.out.println("***很遗憾!取款失败***");
System.out.println("***给您带来的不便深表遗憾***");
System.out.println("***可能是以下原因造成的:***");
System.out.println("***您的余额不足***");
System.out.println("***您输入的取款金额有误***");
System.out.println("***请重新操作***");
System.out.println("***系统自动返回ing***");
withdraw(user,identity,password,balance);
}
}
public static void transfer(String[] user,int[]identity,int[]password,int[]balance){
System.out.println("***"+user[n]+"***");
System.out.println("***欢迎使用转账系统***");
System.out.println("***请输入您要转入的对方名字:");
String username=scan.next();
for (int i = 0; i < user.length; i++) {
if(username.equals(user[i])){
System.out.println("您要转入的是:"+user[i]+"的账户");
System.out.println("请输入转入的金额");
int transfermoney=scan.nextInt();
System.out.println("***正在为您处理ing***");
if(transfermoney>0&&balance[n]>transfermoney){

balance[n]-=transfermoney;
balance[i]+=transfermoney;
System.out.println("***转账成功***");
System.out.println("您的账户余额为:"+balance[n]);
System.out.println("***系统自动返回ing***");
fun1(user,identity,password,balance);
}else{
System.out.println("转账失败");
System.out.println("可能是您的账户余额不足");
System.out.println("可能是您输入的金额有误");
System.out.println("请返回重新操作");
transfer(user,identity,password,balance);
}
}
else{
flag=true;
}

}
if(flag==true){
System.out.println("没找到账户!");
System.out.println("请重新操作!");
flag=false;
transfer(user,identity,password,balance);
}

}
}

简易ATM机的更多相关文章

  1. 模拟ATM机银行系统

    淄博汉企Java基础考核项目 模拟银行自助终端系统 一. 本系统模拟银行用户使用ATM机开户.查询.存款.取款功能,要求使用java语言编程实现. 说明: 1. 对于数据输入异常,可使用java异常处 ...

  2. JAVA - ATM机程序

    ATM机程序 UnionPayTest.java package oo.day06.work; public class UnionPayTest { } interface UnionPay{ // ...

  3. 连接数据库——模拟ATM机查、存、取、开户功能

    1.界面:包含开户.查询.存款.取款.功能 package com.bank.test; /** * * @author Administrator *界面类 */ public class Jiem ...

  4. 第一次尝试使用JAVA编写的ATM机程序

    package study; import java.util.Scanner; public class ATM { private static int[] users = { 111111, 2 ...

  5. 简单的小程序实现ATM机操作

    简单的小程序实现ATM机操作 代码如下: package Day06; import java.util.Scanner; public class TestAccount { public stat ...

  6. emWin实现ATM机界面设计,含uCOS-III和FreeRTOS两个版本

    第1期:ATM机配套例子:V6-900_STemWin提高篇实验_ATM机(uCOS-III)V6-901_STemWin提高篇实验_ATM机(FreeRTOS) 例程下载地址:http://foru ...

  7. ATM机模拟系统

    实验要求 https://pan.baidu.com/s/1Sq5joWyVsNhY8DYiyI4UmQ 源代码 /*信1705-1 20173458 王嘉梁*/ package atm; impor ...

  8. python实现atm机基本操作及购物车

    一.需求分析 ATM机要为用户提供转账,提现,还款,付款,消费流水,操作记录等操作接口 ATM机要为管理员提供创建用户,冻结解冻,修改额度的功能 ATM机管理员认证使用装饰器来实现 购物车要提供管理员 ...

  9. 多用户ATM机(面向对象编程)

    let readline = require('readline-sync'); // 清屏函数 let clear = () => process.stdout.write(process.p ...

随机推荐

  1. Sprint会议计划

    经过饭后的宿舍激烈会议之后...... 1.我们的MASTER是组员董大为 2.这次sprint的目标是四则运算系统 3.每天例会时间地点:每天晚饭后在宿舍 4.实现四则运算的基本功能前期已经完成得差 ...

  2. Voltage Keepsake CodeForces - 801C (思维+二分)

    题目链接 这是一道很棒的二分题. 思路: 首先先思考什么情况下是可以无限的使用,即输出-1. 我们思考可知,如果每一秒内所有设备的用电量总和小于等于充电器每秒可以充的电,那么这一群设备就可以无限使用. ...

  3. phpStorm字体大小无法调整, 怎么办?

    最近上手了一款轻量级IDE phpStorm,可是就在调整编辑器字体大小时却遇到问题了, 发现字体大小无法调整,另外还有字体大小往左还有个“√”,始终无法去掉,这个勾限制了字体系列,就可怜巴巴的那几个 ...

  4. 软件工程_5th weeks

    从周五开始经历了清明小长假,周六.周日和周一都处于假期状态,因此对于上篇博客的评论回复的很迟,而这周的工作做的也不多. 1.爆打小组 4.5日站立会议 时间:2016.4.5 15:00-15:34 ...

  5. 使用TensorFlow实现分类

    这一节使用TF搭建一个简单的神经网络用于分类任务,首先把需要的包引入,另外为了防止在多次运行中一些图中的tensor在内存中影响实验,采取重置操作: import tensorflow as tf i ...

  6. 常见的HTTP报头(头参数)

    本内容摘抄自<RESTful WebServices> 中文译本附录C '常见的HTTP报头'. 原文作者:Leonard Ricbardson & Sam Ruby 翻译:徐涵. ...

  7. html5應用緩存

    HTML5使用了應用緩存,就是web應用緩存,使得在離線狀態下可以訪問web'應用. 應用緩存的優點: 離線訪問-可以在無網的狀態下訪問應用 速度-有緩存的應用加載更快 瀏覽器負載-瀏覽器只從服務器加 ...

  8. docker --swarm创建一个集群

    如果搭建错误可以强制脱离集群网络: docker swarm leave --force 初始化集群网络管理节点: docker swarm init --advertise-addr 10.101. ...

  9. Codeforces Round #419 (Div. 2) C. Karen and Game

    C. Karen and Game time limit per test 2 seconds memory limit per test 512 megabytes input standard i ...

  10. MT【210】四点共圆+角平分线

    (2018全国联赛解答最后一题)在平面直角坐标系$xOy$中,设$AB$是抛物线$y^2=4x$的过点$F(1,0)$的弦,$\Delta{AOB}$的外接圆交抛物线于点$P$(不同于点$A,O,B$ ...