1 thought on “Association”

  1. import java.util.Scanner;

    public class Main
    {
    public static void main(String args[])
    {
    Scanner ob=new Scanner(System.in);
    int n;
    int op;

    System.out.println("How many accounts you want to open?");
    int accnum=ob.nextInt();
    Account accounts[]=new Account[accnum];
    while(accnum>0){
    System.out.println("Plese select below option:1.Saving 2.Fixed");
    n=ob.nextInt();
    Account newAccount;
    if(n==1){
    newAccount=new SavingsAccount();

    System.out.println("Name:");
    String name=ob.nextLine();
    ob.nextLine();
    newAccount.setAccountHolderName(name);
    System.out.println("Account number:");
    int number=ob.nextInt();
    newAccount.setAccountNumber(number);
    System.out.println("Account Balance:");
    double bal=ob.nextDouble();
    newAccount.setBalance(bal);
    System.out.println("Account interaste rate:");
    double rate=ob.nextDouble();
    newAccount(rate);
    newAccount.showDetails();

    }
    else{
    newAccount=new FixedAccount();

    System.out.println("Name:");
    String name=ob.nextLine();
    ob.nextLine();
    newAccount.setAccountHolderName(name);
    System.out.println("Account number:");
    int number=ob.nextInt();
    newAccount.setAccountNumber(number);
    System.out.println("Account Balance:");
    double bal=ob.nextDouble();
    newAccount.setBalance(bal);
    System.out.println("Account interaste rate:");
    int year=ob.nextInt();
    newAccount(year);
    newAccount.showDetails();

    }

    accnum–;

    }
    do
    {
    System.out.println("Select below operation");
    System.out.println("1.Add Money");
    System.out.println("2.Withdraw Money");
    System.out.println("3.Transfer");
    System.out.println("4.");

    }

    /*Customer c = new Customer("+988877655544");
    Account a1 = new SavingsAccount(10);
    /*a1.setInterestRate(10);*/
    /*a1.setAccountNumber(111);
    a1.setAccountHolderName("abc");
    a1.setBalance(500.0);

    c.addAccount(a1);

    Account a2 = new FixedAccount(3);
    //a2.setTenureYear(3);
    a2.setAccountNumber(222);
    a2.setAccountHolderName("def");
    a2.setBalance(20000.0);

    c.addAccount(a2);

    c.showAllAccounts();*/

    }
    }

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top