Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Date;
- import java.util.Scanner;
- class bank
- {
- protected String name;
- protected String nominee;
- protected String id;
- protected double balance;
- protected String accno;
- private account DebitAccount[]=new account[100];
- private int count=0;
- public bank(){
- }
- public void createAccount()//name and other input in this position
- {
- account newAccount= new account();
- this.DebitAccount[count]=newAccount;
- count++;
- Scanner myObj = new Scanner(System.in);
- System.out.print("Enter Account No: ");
- String accno=myObj.nextLine();
- System.out.println("Enter name: " );
- String name = myObj.nextLine();
- //System.out.println("Username is: " + name+"\n");
- System.out.println("Enter nominee: " );
- String nominee = myObj.nextLine();
- //System.out.println("nominee is: " + nominee+"\n");
- // this.id=Idgenerator.getId();
- //System.out.println("your acount no :"+accno);
- //System.out.println("NAME : "+name+" \n"+"account no : "+accno+"\n"+"nominee :"+nominee);
- }
- public String getId()
- {
- return this.id;
- }
- public void print()
- {
- System.out.println("NAME : "+name+" \n"+"account no : "+accno+"\n"+"nominee :"+nominee);
- }
- public double getbalance(){
- return balance;
- }
- boolean search(String acn)
- {
- if(accno.equals(accno))
- {
- print();
- return(true);
- }
- return(false);
- }
- public boolean deposit(String accno,double amount)
- {
- if(balance >100000 && amount>0)
- {
- return false;
- // System.out.println("You have exceed your deposit limit");
- }else{
- balance += amount;
- return true;
- }
- }
- public boolean withdraw(String accno,double amount)
- {
- if (amount >= 0 && amount <= balance)
- {
- balance -= amount;
- return true;
- }
- return false;
- }
- public static void main(String args[])
- {
- bank B= new bank();
- //B.createAccount();
- Scanner in = new Scanner(System.in);
- System.out.print("How Many Customer U Want to Input : ");
- int n=in.nextInt();
- bank C[]=new bank[n];
- for(int i=0;i<C.length;i++)
- {
- C[i]=new bank();
- C[i].createAccount();
- }
- int userChoice ;
- String temp;
- boolean quit = false;
- do {
- // System.out.println("1. Create Account");
- System.out.println("2. Deposit money");
- System.out.println("3. Withdraw money");
- System.out.println("4. Display Account Details");
- System.out.println("0. to quit: \n");
- System.out.print("Enter Your Choice : ");
- userChoice = in.nextInt();
- switch (userChoice) {
- /* case 1:
- System.out.print("Enter your Name : ");
- name=strng.nextLine();
- System.out.print("Enter Accout Type : ");
- System.out.println("\n\tYour Account Details");
- System.out.println("**************************");
- B.printAccount();
- break;*/
- case 2: // deposit
- in.nextLine();
- System.out.print("Enter your account Number : ");
- temp=in.nextLine();
- if(temp.equals(B.accno)){
- System.out.print("Enter Amount Of Money to deposit: ");
- double amount=in.nextDouble();
- if(!B.deposit(B.accno,amount)){
- System.out.println("Please enter positive value or Maybe you have exceeded your deposit Amount .");
- }else{
- System.out.println(" deposited : "+amount+ " The current balance is : "+B.getbalance());
- }
- }
- else {
- System.out.println("Wrong Accoount Number.");
- }
- break;
- case 3: // withdraw
- System.out.print("Enter your account Number : ");
- temp=in.nextLine();
- if(temp.equals(B.accno)){
- System.out.println("Please Enter amount to withdraw");
- double amount = in.nextDouble();
- if(!B.withdraw(B.accno,amount)) {
- System.out.println("not enough balance or negative value");
- }
- else{
- System.out.println("Successfully withdrew $"+amount+". The current balance is "+B.getbalance());
- }
- }
- else {
- System.out.println("Wrong Accoount Number.");
- }
- break;
- case 4: // print all info
- System.out.print("displaying account info :\n");
- //B.print();
- for(int i=0;i<C.length;i++)
- {
- C[i].print();
- }
- break;
- case 0:
- quit = true;
- break;
- default:
- System.out.println("Wrong Choice.");
- break;
- }
- System.out.println("\n");
- } while (!quit);
- //b.printAccountDetails("");
- }
- }
Add Comment
Please, Sign In to add comment