NB52053

Bank

Jul 12th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.05 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Application {
  4.     public static void main(String[] args) {
  5.         Scanner userInput = new Scanner(System.in);
  6.         //Account[] A=new Account[50];
  7.         Savings [] SA = new Savings[50];
  8.         Current [] CA = new Current[50];
  9.         Student [] sa = new Student[50];
  10.  
  11.         int a=0,i=-1,j=-2,x;
  12.  
  13.         do{
  14.             System.out.println(".....Welcome To My Banking System.....");
  15.             System.out.println("Want to open a new accout? Press 1:");
  16.             System.out.println("Want to work with your account? Press 2:");
  17.             System.out.println("Want to Exit:Press 3:");
  18.             System.out.println("Enter Your Choice:");
  19.             x=userInput.nextInt();
  20.  
  21.             if(x==1){
  22.                 System.out.println("...Account Type...");
  23.                 System.out.println("1.For Savings Account Write:'Savings'");
  24.                 System.out.println("2.For Current Account Write:'Current'");
  25.                 System.out.println("3.For Student Account Write:'Student'");
  26.                 System.out.println("What Type Of Account Want To Make? Enter Your choice:");
  27.                 String c1=userInput.next();
  28.                 i++;
  29.                 if(c1.equals("Savings")){
  30.                     System.out.println("Enter your Name:");
  31.                     String name=userInput.next();
  32.                     System.out.println("Enter your Balance:");
  33.                     double balance=userInput.nextDouble();
  34.  
  35.                     SA[i]=new Savings(name,balance);
  36.  
  37.                     System.out.println("Account Holder Name:"+SA[i].getMemberName() + "Account Holder Id:"+SA[i].getAccountNumber());
  38.                 }
  39.  
  40.                 else if(c1.equals("Current")){
  41.                     System.out.println("Enter your Name:");
  42.                     String name=userInput.next();
  43.                     System.out.println("Enter your Balance:");
  44.                     double balance=userInput.nextDouble();
  45.                     System.out.println("Enter your TreadLisence:");
  46.                     int trdLisence=userInput.nextInt();
  47.  
  48.                     CA[i]=new Current(name, balance,trdLisence);
  49.  
  50.                     System.out.println("Account Holder Name:"+CA[i].getMemberName() + "Account Holder Id:"+CA[i].getAccountNumber());
  51.                 }
  52.                 else if(c1.equals("Student")){
  53.                     System.out.println("Enter your Name:");
  54.                     String name=userInput.next();
  55.                     System.out.println("Enter your Balance:");
  56.                     double balance=userInput.nextDouble();
  57.                     System.out.println("Enter your Institute:");
  58.                     String inst=userInput.next();
  59.  
  60.                     sa[i]=new Student(name,balance,inst);
  61.  
  62.                     System.out.println("Account Holder Name:"+sa[i].getMemberName() + "Account Holder Id:"+sa[i].getAccountNumber());
  63.                 }
  64.             }
  65.             else if(x==2) {
  66.  
  67.                 System.out.println("Input Your Id:");
  68.                 String y = userInput.next();
  69.                 for (j = 0; j <= i; j++) {
  70.                     if (y.equals(SA[j].getAccountNumber())) {
  71.                         break;
  72.                     }
  73.                   }
  74.                 }
  75.  
  76.  
  77.             if(j>=0){
  78.                 do{
  79.                     System.out.println("Want to Deposite Money Press 1:");
  80.                     System.out.println("Want to Withdrawl Money Press 2:");
  81.                     System.out.println("Want Display Account Details Press 3:");
  82.                     System.out.println("Return to Banking System Press 0:");
  83.  
  84.                     a= userInput.nextInt();
  85.                     if (a == 1) {
  86.  
  87.                         System.out.println("Enter How Much Money You Want TO Deposite:");
  88.                         double ammount= userInput.nextDouble();
  89.                         SA[j].deposite(ammount);
  90.                     }
  91.  
  92.                     else if (a== 2) {
  93.                         System.out.println("Enter How Much Money You Want TO Withdrawl:");
  94.                         double ammount= userInput.nextDouble();
  95.                         SA[j].withdrawl(ammount);
  96.                     }
  97.  
  98.                     else if (a == 3) {
  99.                         SA[j].display();
  100.                     }
  101.  
  102.                     else{
  103.                         System.out.println("Exit from account");
  104.                         break;
  105.                     }
  106.                 }while(a!=0);
  107.             }
  108.         }while(x!=0);
  109.     }
  110. }
  111.  
  112. import java.util.Random;
  113.  
  114. public class BankAccount {
  115.  
  116.     String memberName;
  117.     String accountNumber;
  118.     double accountBalance;
  119.     double minimumBalance;
  120.  
  121.     public String getMemberName(){
  122.         return memberName;
  123.     }
  124.  
  125.     public void setMemberName(String memberName) {
  126.         this.memberName = memberName;
  127.     }
  128.     public String getAccountNumber() {
  129.         return accountNumber;
  130.     }
  131.     public void setAccountNumber(String accountNumber){
  132.         this.accountNumber = accountNumber;
  133.     }
  134.     public double getAccountBalance(){
  135.         return accountBalance;
  136.  
  137.     }
  138.     public void setAccountBalance(double accountBalance) {
  139.         this.accountBalance = accountBalance;
  140.     }
  141.  
  142.     public BankAccount(String memberName,double accountBalance,double minimumBalance){
  143.         this.memberName =memberName;
  144.         this.accountBalance =accountBalance;
  145.         this.minimumBalance=minimumBalance;
  146.  
  147.         Random rand=new Random();
  148.         this.accountNumber =10000+rand.nextInt(89999)+"";
  149.     }
  150.  
  151.  
  152.     public void deposite(double ammount)
  153.     {
  154.         setAccountBalance(getAccountBalance()+ammount);
  155.  
  156.     }
  157.  
  158.     void withdrawl(double ammount)
  159.     {
  160.         double withdraw;
  161.         withdraw = accountBalance -ammount;
  162.         if(withdraw >= minimumBalance){
  163.             accountBalance = withdraw;
  164.         }
  165.  
  166.     }
  167.  
  168.  
  169.  
  170.     public double getBalance() {
  171.  
  172.         return accountBalance;
  173.     }
  174.  
  175.  
  176.  
  177.     void display(){
  178.         System.out.println("Name:"+ getMemberName()+" "+"Id:"+ getAccountNumber()+" "+"Balance:"+ getAccountBalance());
  179.     }
  180. }
  181.  
  182. public class Current extends BankAccount{
  183.  
  184.     public int tradeLicense;
  185.  
  186.  
  187.     public Current(String name,double balance,int trdLicense) {
  188.         super(name, balance,5000);
  189.         this.tradeLicense=trdLicense;
  190.     }
  191.     }
  192.  
  193. public class Savings extends BankAccount {
  194.  
  195.  
  196.     double interest=0.05;
  197.     double MaxWithdrawLimit;
  198.  
  199.     public Savings(String name, double balance) {
  200.         super(name, balance, 2000);
  201.         MaxWithdrawLimit =50000 ;
  202.     }
  203.  
  204.     public double getBalance(int year){
  205.         return getAccountBalance()+(getAccountBalance()*interest)*year;
  206.     }
  207.  
  208.  
  209.     public double getOriginalBalance(){
  210.  
  211.         return accountBalance;
  212.  
  213.     }
  214. }
  215.  
  216. public class Student extends Savings {
  217.  
  218.     String institute;
  219.  
  220.     public Student(String name,double balance,String inst){
  221.         super(name,balance);
  222.         this.institute = inst;
  223.         MaxWithdrawLimit =20000;
  224.         minimumBalance=100;
  225.     }
  226.  
  227.  
  228. }
Add Comment
Please, Sign In to add comment