最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

java實(shí)現(xiàn)簡(jiǎn)單銀行管理系統(tǒng)

 更新時(shí)間:2019年12月26日 14:16:52   作者:weihubeats  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡(jiǎn)單銀行管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了java銀行管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

賬戶類

package Account;
 
public abstract class Account {
  private int id;//賬號(hào)
  private String password;//密碼
  private String name;//姓名
  private String personId;//身份證號(hào)碼
  private String email;//郵箱
  private double ceiling;//貸款屬性
  private static double balance;//賬戶余額
  
  public Account() {}
 
  public Account(int id, String password, String name, String personId,
      String email, double balance,double ceiling) {
    super();
    this.id = id;
    this.password = password;
    this.name = name;
    this.personId = personId;
    this.email = email;
    this.balance = balance;
    this.ceiling = ceiling;
  }
  public Account(int id, String password, String name, String personId,
      String email) {
    super();
    this.id = id;
    this.password = password;
    this.name = name;
    this.personId = personId;
    this.email = email;
  }
  public Account(int id, String password) {
    this.id =id;
    this.password = password;
  }
  //開戶函數(shù)
  public Account openAccount() {
    return null;
  }
  //顯示開戶成功的信息函數(shù)
  public void show() {
    System.out.println("賬戶ID為 : " + id + "密碼為: " + password + "姓名為: " + name + "身份證號(hào)碼為: " + personId + "郵箱為:  " + email);
  }
  //登入函數(shù)
  public void enter() {
    
  }
  //取款方法 為抽象方法
  public abstract void deposit(double money); 
    
  //存款方法
  public static void withdraw(double money) {
    balance = balance + money;
      System.out.println("您已經(jīng)存入" + money + "元,賬戶余額為" + balance );
  }
//  public abstract void requestLoan(double money);
 
  public double getCeiling() {
    return ceiling;
  }
 
  public void setCeiling(double ceiling) {
    this.ceiling = ceiling;
  }
 
  public int getId() {
    return id;
  }
  public void setId( int id) {
    this.id = id;
  }
 
  public String getPassword() {
    return password;
  }
 
  public void setPassword(String password) {
    this.password = password;
  }
 
  public String getName() {
    return name;
  }
 
  public void setName(String name) {
    this.name = name;
  }
 
  public String getPersonId() {
    return personId;
  }
 
  public void setPersonId(String personId) {
    this.personId = personId;
  }
 
  public String getEmail() {
    return email;
  }
 
  public void setEmail(String email) {
    this.email = email;
  }
 
  public double getBalance() {
    return balance;
  }
  public void setBalance(double balance) {
    this.balance = balance;
  }
 
  
  
}

Bank類

package Account;
 
import java.util.Scanner;
 
public class Bank {
  int i;// 賬戶編號(hào)
  private Account[] account = new Account[100];// 賬戶對(duì)象數(shù)組
  private int accountNum = 0;// 賬戶數(shù)量
  private int type;// 賬戶類型
  private String password1;// 確認(rèn)密碼
  int id = 100000;//第一個(gè)開戶賬號(hào)
  int j = 1;//常量控制開戶賬號(hào)每次+1
  Scanner sc = new Scanner(System.in);
  int insert;
 
  public Bank() {
  }
 
  // 主界面
  public void mainView() {
    System.out.println("******歡迎登入銀行管理系統(tǒng)********");
    System.out.println("******請(qǐng)選擇業(yè)務(wù)***************");
    System.out.println("******1、創(chuàng)建賬戶**************");
    System.out.println("******2、登入賬戶**************");
  }
 
  //功能選擇函數(shù)
  public void select() {
    int select = sc.nextInt();
    switch(select) {
    case 1 : this.openAccount();
    break;
    case 2 : this.enter();
    break;
    }
 
 
  }
 
  // 開戶函數(shù)
  public Account openAccount() {
    System.out.println("請(qǐng)輸入您的姓名");
    String name = sc.next();
 
    //    System.out.println("請(qǐng)輸入您的卡號(hào)");
    //    int id = sc.nextInt();
    System.out.println("請(qǐng)輸入您的密碼");
    String password = sc.next();
 
    System.out.println("請(qǐng)?jiān)俅未_認(rèn)您的密碼");
    String password1 = sc.next();
    while (!password1.equals(password)) {
      System.out.println("對(duì)不起,兩次輸入的密碼不一致,請(qǐng)重新輸入");
      System.out.println("請(qǐng)重新輸入您的密碼");
      password = sc.next();
      System.out.println("請(qǐng)?jiān)俅未_認(rèn)您的密碼");
      password1 = sc.next();
    }
 
    System.out.println("請(qǐng)輸入您的身份證號(hào)碼");
    String personId = sc.next();
 
    System.out.println("請(qǐng)輸入您的郵箱");
    String email = sc.next();
 
    System.out.println("請(qǐng)輸入您的賬戶類型");
    System.out.println("1、存儲(chǔ)卡            2、信用卡");
    type = sc.nextInt();
    switch (type) {
    case 1:
      account[accountNum] = new LoanSavingAccount(100000 + j, password, name,
          personId, email, 0, 0); // 創(chuàng)建存儲(chǔ)卡賬戶對(duì)象,初始余額為0,默認(rèn)貸款金額為0元
      account[accountNum].show();//調(diào)用顯示賬戶信息函數(shù)
      System.out.println("卡類型為:存儲(chǔ)卡");
      accountNum++;
      j++;
      return account[accountNum];
    case 2:
      account[accountNum] = new LoanCreditAccount(100000 + j, password, name,
          personId, email, 0, 0, 5000); // 創(chuàng)建信用卡賬戶對(duì)象,多一個(gè)透資屬性,初始透資金額為5000元
      account[accountNum].show();//調(diào)用顯示賬戶信息函數(shù)a
      System.out.println("卡類型為: 信用卡");
      accountNum++;
      j++;
      return account[accountNum];
    }
    return null;
 
  }
 
  // System.out.println("恭喜您,創(chuàng)建賬號(hào)成功啦?。?!" + "您的賬號(hào)名為"+ account.getId() +
  // "您的賬戶類型為" + type);
  // return account;
 
  // 登入函數(shù)
  public Account enter() {
    System.out.println("請(qǐng)輸入您的銀行卡號(hào)");
    int id = sc.nextInt();
    System.out.println("請(qǐng)輸入您的密碼");
    String password = sc.next();
    if (accountNum == 0) {
      System.out.println("未注冊(cè)賬戶,請(qǐng)先注冊(cè)!");
      this.openAccount();
      this.mainView();
      this.select();
    } 
    boolean flag = false;
    for (i = 0; i < accountNum; i++) {
      if (id == account[i].getId() && password.equals(account[i].getPassword())) {//判斷Id和輸入的賬戶密碼是否一致
        flag = true;
        break;
      }
    }
    if (!flag) {
      System.out.println("登入失?。。。?);
    }
    if (flag) {
      System.out.println("登入成功!!!!");
      do {
        System.out.println("請(qǐng)選擇業(yè)務(wù)");
        System.out.println("******1、存款*****************");
        System.out.println("******2、取款*****************");
        System.out.println("******3、貸款*****************");
        System.out.println("******4、還款*****************");
        System.out.println("******3、按任意鍵退出*************");
        insert = sc.nextInt();
        switch(insert) {
        case 1 :   
          System.out.println("******請(qǐng)輸入存款金額*****************");
          int money = sc.nextInt();
          account[i].withdraw(money);                
          break;
 
        case 2:   System.out.println("******請(qǐng)輸入取款金額*****************");
        money = sc.nextInt();
        account[i].deposit(money);//調(diào)用取款方法
        break;
 
        case 3:   judge();
               break;
 
 
        case 4:   repay();
               break;
        }
      } while(insert == 1 || insert == 2 || insert == 3 || insert == 4);
 
    }  
    return account[i];
 
 
  }
 
  //存款方法
  public void withdraw() {
    System.out.println("請(qǐng)輸入存款金額");
    int money = sc.nextInt();
    account[i].withdraw(money);
  }
  //取款方法
  public void deposit() {
    System.out.println("請(qǐng)輸入取款金額");
    int money = sc.nextInt();
    account[i].deposit(200);
  }
 
  //計(jì)算銀行余額總數(shù)方法
  public void Accountsum() {
    double savSum = 0;
    for (int i = 0; i < accountNum; i++) {
      savSum += account[i].getBalance();
    }
  }
 
  //判斷是LoanSavingAccount 類還是LoacCreditAccount
  //貸款方法
  public void judge() {
    System.out.println("******請(qǐng)輸入貸款金額*****************");
    int money = sc.nextInt();
    if (account[accountNum - 1] instanceof LoanSavingAccount) {
      LoanSavingAccount a = (LoanSavingAccount) account[accountNum - 1];
      a.requestLoan(money);
    }else {
      LoanCreditAccount b = (LoanCreditAccount) account[accountNum -1 ];
      b.requestLoan(money);
      System.out.println("成功調(diào)用了貸款方法");
    }
 
  }
 
  //還款方法
  public void repay() {
    System.out.println("******請(qǐng)輸入還款金額*****************");
    int money = sc.nextInt();
    if (account[accountNum - 1] instanceof LoanSavingAccount) {
//      System.out.println("判斷過(guò)了1");
      LoanSavingAccount a = (LoanSavingAccount) account[accountNum - 1];
      a.payLoan(money);
    }else {
//      System.out.println("判斷過(guò)了2");
      LoanCreditAccount b1 = (LoanCreditAccount) account[accountNum - 1];
      b1.payLoan(money);
    }
 
  }
 
 
}

信用卡類

package Account;
 
 
public class CreditAccount extends Account {  //信用卡
  private double overdraft;//透資屬性
  
  public CreditAccount() {}
 
  public CreditAccount(int id, String password, String name, String personId,String email, double balance, double ceiling, double overdraft) {
    super(id,password,name, personId, email, balance, ceiling);
    this.overdraft = overdraft;//多出一個(gè)透資屬性
  }
  
 
 
  //  public void withdraw(double money) {
//    super.setBalance(super.getBalance() + money);
//    System.out.println("你的卡號(hào)為" + super.getId() +"的卡,您已經(jīng)存入" + money + "元,賬戶余額為" + super.getBalance() );
//  }
  public void deposit(double money) {//信用卡取款方法
    if ((super.getBalance() + overdraft) >= money) {
       super.setBalance(super.getBalance() - money) ;
       System.out.println("您取了" + money + "錢,您的余額為" + super.getBalance());
    }else System.out.println("對(duì)不起您的余額和透支額度不足!");
    
    
  }
 
//  @Override
//  public void requestLoan() {
//    // TODO Auto-generated method stub
//    
//  }
  
 
}
 
 
package Account;
 
public interface General {
  void requestLoan(double money);//貸款方法
  void payLoan(double money);//還款
//  void getLoan();//獲取用戶總額
  
 
}

信用卡子類

package Account;
 
import java.util.Scanner;
 
 
public class LoanCreditAccount extends CreditAccount implements General {
  Scanner sc = new Scanner(System.in);
 
  public LoanCreditAccount(){}
  public LoanCreditAccount(int id, String password, String name, String personId,String email, double balance, double ceiling,double overdraft) {
    super(id, password, name, personId, email, balance, ceiling, overdraft);
  }
  public void requestLoan(double money) {//貸款方法
    if ( 0 <= money&& money <= 10000) {//貸款上限為10000
      System.out.println("貸款成功,您的貸款金額為: " + money);
      System.out.println("您還能貸款的金額為: " + (10000 - money));
      super.setCeiling(money);//把貸款的錢傳給貸款屬性
      super.setBalance(super.getBalance() + money);//更新余額值
      System.out.println("您現(xiàn)在的余額為: " + super.getBalance());
    }else {
      System.out.println("對(duì)不起您的額度不夠,貸款失??!");
    }
  }
  public void payLoan(double money) {//還款
    //三個(gè)判斷條件:1. 還款金額小于等于貸款金額  2.還款金額小于所剩余額 3.還款金額大于0
    
    if (super.getBalance() >= money && money <= super.getCeiling() && money >= 0) {
      super.setBalance(super.getBalance() - money); //更新余額
      super.setCeiling(super.getCeiling() - money);
      System.out.println(" 您現(xiàn)在的余額為" + super.getBalance());
      if (super.getCeiling() ==0) {
        System.out.println("您已經(jīng)全部還清!!謝謝光臨!!");
      }else {
        
        System.out.println("您已經(jīng)還了" + money +"您還需要還" + super.getCeiling() );
      }
    }else {
      System.out.println("對(duì)不起,您的賬戶余額不足或者輸入的還款額度超出范圍!");
    }
    
  }
  public void getLoan() {//獲取用戶貸款總額
    double savSum = 0;
  };
 
}

package Account;
 
import java.util.Scanner;
 
import com_Day_7_11.SavingAccount;
 
 
//存儲(chǔ)卡子類
public class LoanSavingAccount extends SavingAccount implements General{
  Scanner sc = new Scanner(System.in);
 
 
  public LoanSavingAccount(int id, String password, String name,
      String personId, String email, double balance, double ceiling) {
    super(id, password, name, personId, email, balance, ceiling);
    
  }
  public void requestLoan(double money) {//貸款方法
    if ( 0 <= money&& money <= 10000) {//貸款上限為10000
      System.out.println("貸款成功,您的貸款金額為: " + money);
      System.out.println("您還能貸款的金額為: " + (10000 - money));
      super.setCeiling(money);//把貸款的錢傳給貸款屬性
      super.setBalance(super.getBalance() + money);//更新余額值
      System.out.println("您現(xiàn)在的余額為: " + super.getBalance());
    }else {
      System.out.println("對(duì)不起您的額度不夠,貸款失??!");
    }
  }
  public void payLoan(double money) {//還款
    //三個(gè)判斷條件:1. 還款金額小于等于貸款金額  2.還款金額小于所剩余額 3.還款金額大于0
    
    if (super.getBalance() >= money && money <= super.getCeiling() && money >= 0) {
      super.setBalance(super.getBalance() - money); //更新余額
      super.setCeiling(super.getCeiling() - money);
      System.out.println(" 您現(xiàn)在的余額為" + super.getBalance());
      if (super.getCeiling() ==0) {
        System.out.println("您已經(jīng)全部還清??!謝謝光臨!!");
      }else {
        
        System.out.println("您已經(jīng)還了" + money +"您還需要還" + super.getCeiling() );
      }
    }else {
      System.out.println("對(duì)不起,您的賬戶余額不足或者輸入的還款額度超出范圍!");
    }
    
  }
 
}

主界面測(cè)試函數(shù)

package Account;
 
import java.util.Scanner;
 
 
public class Text {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
 
    Bank b = new Bank();
    while (true) {
      b.mainView();//調(diào)用界面函數(shù)
      int select = sc.nextInt();
      switch(select) {
      case 1: b.openAccount();//創(chuàng)建賬戶
        break;
      case 2: b.enter();//登入
          break;  
      default: System.out.println("選擇業(yè)務(wù)異常,請(qǐng)重新選擇");
      break;
      }
      System.out.println("是否繼續(xù)選擇其他業(yè)務(wù)");
      System.out.println("退出請(qǐng)按  0");
      System.out.println("繼續(xù)選擇其他業(yè)務(wù)請(qǐng)按 1");
      select = sc.nextInt();
      if (select == 0) {
        break;
      }
    }
 
  }
 
}

更多學(xué)習(xí)資料請(qǐng)關(guān)注專題《管理系統(tǒng)開發(fā)》。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Mybatis三種批量插入數(shù)據(jù)的方式

    Mybatis三種批量插入數(shù)據(jù)的方式

    這篇文章主要介紹了Mybatis的三種批量插入方式,幫助大家更好的理解和學(xué)習(xí)使用Java,感興趣的朋友可以了解下
    2021-04-04
  • 關(guān)于Assert.assertEquals報(bào)錯(cuò)的問(wèn)題及解決

    關(guān)于Assert.assertEquals報(bào)錯(cuò)的問(wèn)題及解決

    這篇文章主要介紹了關(guān)于Assert.assertEquals報(bào)錯(cuò)的問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • springboot整合xxl-job的示例代碼

    springboot整合xxl-job的示例代碼

    這篇文章主要介紹了springboot整合xxl-job的示例代碼,主要分為三大模塊,分別是調(diào)度中心、執(zhí)行器和配置定時(shí)任務(wù)的過(guò)程,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-06-06
  • springboot集成redis實(shí)現(xiàn)消息的訂閱與發(fā)布

    springboot集成redis實(shí)現(xiàn)消息的訂閱與發(fā)布

    本文主要介紹了springboot集成redis實(shí)現(xiàn)消息的訂閱與發(fā)布,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2024-05-05
  • Spring Boot與前端配合與Idea配置部署操作過(guò)程

    Spring Boot與前端配合與Idea配置部署操作過(guò)程

    這篇文章主要介紹了Spring Boot與前端配合與Idea配置部署的操作過(guò)程,本文圖文并茂給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2018-02-02
  • Spring如何自定義加載配置文件(分層次加載)

    Spring如何自定義加載配置文件(分層次加載)

    這篇文章主要介紹了Spring如何自定義加載配置文件(分層次加載)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • 基于Java中throw和throws的區(qū)別(詳解)

    基于Java中throw和throws的區(qū)別(詳解)

    下面小編就為大家?guī)?lái)一篇基于Java中throw和throws的區(qū)別(詳解)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-07-07
  • 淺談Java中return和finally的問(wèn)題

    淺談Java中return和finally的問(wèn)題

    在Java中當(dāng)try、finally語(yǔ)句中包含return語(yǔ)句時(shí),執(zhí)行情況到底是怎樣的,finally中的代碼是否執(zhí)行,大家眾說(shuō)紛紜,有的說(shuō)會(huì)執(zhí)行,有的說(shuō)不會(huì)執(zhí)行,到底哪種說(shuō)法正確,下面我們來(lái)詳細(xì)討論下
    2015-10-10
  • Java設(shè)計(jì)模式之java組合模式詳解

    Java設(shè)計(jì)模式之java組合模式詳解

    這篇文章主要介紹了JAVA設(shè)計(jì)模式之組合模式,簡(jiǎn)單說(shuō)明了組合模式的原理,并結(jié)合實(shí)例分析了java組合模式的具體用法,需要的朋友可以參考下
    2021-09-09
  • Java類的加載時(shí)機(jī)與過(guò)程

    Java類的加載時(shí)機(jī)與過(guò)程

    這篇文章主要介紹了Java類的加載時(shí)機(jī)與過(guò)程,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2021-12-12

最新評(píng)論

红原县| 浦江县| 玉田县| 凌云县| 宾川县| 乐都县| 石屏县| 合山市| 新郑市| 区。| 乾安县| 乾安县| 始兴县| 科技| 射阳县| 南漳县| 石嘴山市| 彭州市| 松阳县| 沅江市| 内江市| 承德市| 武平县| 奉节县| 江孜县| 略阳县| 石家庄市| 沛县| 黄山市| 饶河县| 龙川县| 镶黄旗| 顺义区| 吉木乃县| 陈巴尔虎旗| 金秀| 广东省| 黔东| 武宁县| 宣化县| 诸城市|