• 考试


    //信1705-2班 20173552 白明霞
    package accountinformation;
    public class account {
    private String accountID;
    private String accountname;
    private String operatedate;
    private String accountpassword;
    private int operatetype;
    private int accountbalance;
    private int amount;
    public void set_accountID(String ID){
     accountID=ID;
    }
    public String get_accountID() {
     return accountID;
    }
    void set_accountname(String na) {
     accountname=na;
    }
    String get_accountname() {
     return accountname;
    }
    void set_operatedate(String date) {
     operatedate=date;
    }
    String get_operatedate() {
     return operatedate;
    }
    void set_accountpassword(String word) {
     accountpassword=word;
    }
    String get_accountpassword() {
     return accountpassword;
    }
    void set_operatetype(int type) {
     operatetype=type;
    }
    int get_operatetype() {
     return operatetype;
    }
    void set_accountbalance(int ba) {
     accountbalance=ba;
    }
    int get_accountbalance() {
     return accountbalance;
    }
    void set_amount(int am) {
     amount=am;
    }
    int get_amount(){
     return amount;
    }
    }
     
     
     
     

    package accountinformation;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.util.Scanner;
    import java.util.UUID;
    /*public class accountmanager {
        public static String txt2String(File file){
            StringBuilder result = new StringBuilder();
            try{
                BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
                String s = null;
                while((s = br.readLine())!=null){//使用readLine方法,一次读一行
                    result.append(System.lineSeparator()+s);
                }
                br.close();   
            }catch(Exception e){
                e.printStackTrace();
            }
            return result.toString();
        }
       
        public static void main(String[] args){
            File file = new File("C:/accountinformation.txt");
            System.out.println(txt2String(file));
        }
    }
    */
     
    public class accountmanager {
    static int accountbalance=0;
    static account[] account=new account[10];
    public static void main(String args[]) {
     Scanner input = new Scanner(System.in);
        String cardNum = "20173552"; // 卡号
        int pwd = 123456; // 密码
        boolean flag = true; // 声明布尔类型变量
        double surplus = 1000;// 余额
        System.out.println("***************************************************************");
        System.out.println("---------欢迎使用工商银行ATM机---------");
        System.out.println("***************************************************************");
        /** 用于进行登录的次数限制止 **/
        for (int i = 1; i <= 3; i++) {
         System.out.println("****************************************************************");
            System.out.println("请插入您的银行卡:");
            String inputCard = input.next();
            System.out.println("****************************************************************");
            System.out.println("请输入您的密码:");
            int inputPwd = input.nextInt();
            // 验证账号和密码
            if (inputCard.equals(cardNum) && inputPwd == pwd) {
                flag = true;
                break;
            } else {
                if (i <= 2) {
                    System.out.println("对不起,密码输入不正确,你还有" + (3 - i) + "次机会!");
                } else {
                    System.out.println("对不起,卡已被锁定!");
                    break;
                }
                flag = false;
            }
        }
        /** 登录成功后选择功能 */
        if (flag) {
            char answer = 'y';
            while (answer == 'y') {
             System.out.println("****************************************************************");
                System.out.println("请选择功能:1.取款    2.存款    3.查询余额    4.转账   5.退出");
                System.out.println("****************************************************************");
                int choice = input.nextInt();
                switch (choice) {
                case 1:
                 System.out.println("****************************************************************");
                    System.out.println("取款");
                    System.out.println("****************************************************************");
                    System.out.println("请输入取款金额:");
                    double getMoney = input.nextDouble();
                    if (getMoney > 0) {
                        if (getMoney <= surplus) {
                            if (getMoney % 100 == 0) {
                                System.out.println("请取走您的钞票!余额为¥" + (surplus - getMoney));
                            } else {
                                System.out.println("对不起,不能取零钱!");
                            }
                        } else {
                            System.out.println("对不起,余额不足!");
                        }
                    } else {
                        System.out.println("请输入正确的金额:");
                    }
                    break;
                case 2:
                 System.out.println("****************************************************************");
                    System.out.println("存款");
                    System.out.println("****************************************************************");
                    System.out.println("请把钞票整理后放入存钞口:");
                    double saveMoney = input.nextDouble();
                    if (saveMoney > 0 && saveMoney <= 10000) {
                        if (saveMoney % 100 == 0) {
                            surplus += saveMoney;
                            System.out.println("存款成功!余额为¥" + surplus);
                        } else {
                            double backMoney = saveMoney % 100;
                            surplus = saveMoney + surplus - backMoney;
                            System.out.println("存款成功!余额为¥" + surplus);
                            System.out.println("请取走零钱¥" + backMoney);
                        }
                    } else if (saveMoney > 10000) {
                        System.out.println("一次最多存入一万元,请分批存入!");
                    }
                    break;
                case 3:
                 System.out.println("****************************************************************");
                    System.out.println("查询余额");
                    System.out.println("****************************************************************");
                    System.out.println("您卡上的余额是:" + surplus);
                    break;
                case 4:
                 System.out.println("****************************************************************");
                    System.out.println("转账");
                    System.out.println("****************************************************************");
                    System.out.println("请输入转账金额:");
                    double goMoney = input.nextDouble(); // 转账金额
                    if (goMoney > 0) {
                        if (goMoney <= surplus) {
                            System.out.println("转账成功!余额为¥" + (surplus - goMoney));
                        } else {
                            System.out.println("对不起,请确保卡上有足够的余额!");
                        }
                    } else {
                        System.out.println("转账失败!请输入正确的金额:");
                    }
                    break;
                case 5:
                 System.out.println("****************************************************************");
                     System.out.println("退出");
                     System.out.println("****************************************************************");
                    System.out.println("谢谢您的使用!");
                  
                    break;
                }// switch end
                System.out.println("继续吗?y/n");
                answer = input.next().charAt(0);
            } // while end
            System.out.println("谢谢使用!");
        }
    }
    }
  • 相关阅读:
    利用RxJava获取手机已安装的App的图片、应用名称和版本号
    个人开源作品,即时通讯App支持文本、语音、图片聊天
    将博客搬至CSDN
    Fragments之间的交互(实现参数传递)
    Android ListView用EditText实现搜索功能
    自定义控件--CircleImageView(类似于QQ、微信圆形头像自定义控件)
    js获取当天0点和24点的时间戳
    js将时间转换为时间戳在苹果手机上为NaN
    根据当前日期获取本周的日期数组
    js中页面加载完成后执行的几种方式及执行顺序
  • 原文地址:https://www.cnblogs.com/baixiaoli/p/9687899.html
Copyright © 2020-2023  润新知