国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

java如何實(shí)現簡(jiǎn)單銀行管理系統

發(fā)布時(shí)間:2021-09-27 17:50 來(lái)源:億速云 閱讀:0 作者:小新 欄目: 開(kāi)發(fā)技術(shù)

這篇文章主要介紹了java如何實(shí)現簡(jiǎn)單銀行管理系統,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著(zhù)大家一起了解一下。

具體內容如下

賬戶(hù)類(lèi)

package Account; public abstract class Account {  private int id;//賬號  private String password;//密碼  private String name;//姓名  private String personId;//身份證號碼  private String email;//郵箱  private double ceiling;//貸款屬性  private static double balance;//賬戶(hù)余額    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;  }  //開(kāi)戶(hù)函數  public Account openAccount() {    return null;  }  //顯示開(kāi)戶(hù)成功的信息函數  public void show() {    System.out.println("賬戶(hù)ID為 : " + id + "密碼為: " + password + "姓名為: " + name + "身份證號碼為: " + personId + "郵箱為:  " + email);  }  //登入函數  public void enter() {      }  //取款方法 為抽象方法  public abstract void deposit(double money);       //存款方法  public static void withdraw(double money) {    balance = balance + money;      System.out.println("您已經(jīng)存入" + money + "元,賬戶(hù)余額為" + 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類(lèi)

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

信用卡類(lèi)

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("你的卡號為" + super.getId() +"的卡,您已經(jīng)存入" + money + "元,賬戶(hù)余額為" + super.getBalance() );//  }  public void deposit(double money) {//信用卡取款方法    if ((super.getBalance() + overdraft) >= money) {       super.setBalance(super.getBalance() - money) ;       System.out.println("您取了" + money + "錢(qián),您的余額為" + super.getBalance());    }else System.out.println("對不起您的余額和透支額度不足!");          } //  @Override//  public void requestLoan() {//    // TODO Auto-generated method stub//    //  }   }  package Account; public interface General {  void requestLoan(double money);//貸款方法  void payLoan(double money);//還款//  void getLoan();//獲取用戶(hù)總額   }

信用卡子類(lèi)

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);//把貸款的錢(qián)傳給貸款屬性      super.setBalance(super.getBalance() + money);//更新余額值      System.out.println("您現在的余額為: " + super.getBalance());    }else {      System.out.println("對不起您的額度不夠,貸款失??!");    }  }  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(" 您現在的余額為" + super.getBalance());      if (super.getCeiling() ==0) {        System.out.println("您已經(jīng)全部還清??!謝謝光臨!!");      }else {                System.out.println("您已經(jīng)還了" + money +"您還需要還" + super.getCeiling() );      }    }else {      System.out.println("對不起,您的賬戶(hù)余額不足或者輸入的還款額度超出范圍!");    }      }  public void getLoan() {//獲取用戶(hù)貸款總額    double savSum = 0;  }; }

package Account; import java.util.Scanner; import com_Day_7_11.SavingAccount;  //存儲卡子類(lèi)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);//把貸款的錢(qián)傳給貸款屬性      super.setBalance(super.getBalance() + money);//更新余額值      System.out.println("您現在的余額為: " + super.getBalance());    }else {      System.out.println("對不起您的額度不夠,貸款失??!");    }  }  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(" 您現在的余額為" + super.getBalance());      if (super.getCeiling() ==0) {        System.out.println("您已經(jīng)全部還清??!謝謝光臨!!");      }else {                System.out.println("您已經(jīng)還了" + money +"您還需要還" + super.getCeiling() );      }    }else {      System.out.println("對不起,您的賬戶(hù)余額不足或者輸入的還款額度超出范圍!");    }      } }

主界面測試函數

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();//調用界面函數      int select = sc.nextInt();      switch(select) {      case 1: b.openAccount();//創(chuàng )建賬戶(hù)        break;      case 2: b.enter();//登入          break;        default: System.out.println("選擇業(yè)務(wù)異常,請重新選擇");      break;      }      System.out.println("是否繼續選擇其他業(yè)務(wù)");      System.out.println("退出請按  0");      System.out.println("繼續選擇其他業(yè)務(wù)請按 1");      select = sc.nextInt();      if (select == 0) {        break;      }    }   } }

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自互聯(lián)網(wǎng)轉載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權請聯(lián)系QQ:712375056 進(jìn)行舉報,并提供相關(guān)證據,一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容。

国产性色ΑV视频免费| 国产精品久久久天天影视香蕉| 精品日产一区二区三区| 免费女人高潮流视频在线观看| 在线观看免费人成视频色| 又色又爽又黄的视频软件APP|