Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

ACCOUNT

using System;

namespace MID_ASSIGNMENT
{
class Account
{
public double currentBalance = 0.0;
public int accountNumber;
public string accountName;
public string address;

public string AccountName


{
set { this.accountName = value; }
get { return this.accountName; }
}

public string Address


{
set { this.address = value; }
get { return this.address; }
}

public int AccountNumber


{
set { this.accountNumber = value; }
get { return this.accountNumber; }
}

public void Deposit(double amount)


{

currentBalance = currentBalance + amount;


Console.WriteLine("Balnce: " + currentBalance);
}

public void Withdraw(double amount)


{

if (amount != 0 && amount >= 1100 && currentBalance >= amount)


{
currentBalance = currentBalance - amount;
Console.WriteLine("Giving Money: " + amount);
Console.WriteLine("Current Money: " + currentBalance);

else
{
Console.WriteLine(" Balance is insufficient!!");
}
}
internal void DeleteAccount()
{
throw new NotImplementedException();
}

public void Transfer(int accountReceiver, double money)


{

if (accountReceiver == AccountNumber)
{
currentBalance = currentBalance - money;
Console.WriteLine("Transferred money: " + money);
Console.WriteLine("current balance: " + currentBalance);

else
{
Console.WriteLine("Invalid account number!!");
}

static void account (string[] args)


{
Account a1 = new Account();

a1.accountName = "Indro";
a1.AccountNumber = 11111;
a1.address = "Dhaka";

do
{
Console.WriteLine("1.Account information\n 2.Deposit money\n 3.Withdraw
money\n 4.Transfer money");
Console.WriteLine("Enter your choice: ");

int input = System.Convert.ToInt32(System.Console.ReadLine());

if (input != 0)
{
if (input == 1)
{
Console.WriteLine("Account Information");
Console.WriteLine("Account Number: " + a1.AccountNumber);
Console.WriteLine("Account Holder Name: " + a1.AccountName);
Console.WriteLine("Account Holder Address: " + a1.Address);
Console.WriteLine("Balance: " + a1.currentBalance);

if (input == 2)
{
Console.WriteLine("Deposit");
Console.WriteLine("Enter Amount: ");
double amount =
System.Convert.ToDouble(System.Console.ReadLine());

a1.Deposit(amount);
}

if (input == 3)
{
Console.WriteLine("Withdraw");

Console.WriteLine("Enter amount: ");


double amount =
System.Convert.ToDouble(System.Console.ReadLine());
a1.Withdraw(amount);
}

if (input == 4)
{
Console.WriteLine("Transfer");

Console.WriteLine("Enter account What To Transfer: ");

int accountReceiver =
System.Convert.ToInt32(System.Console.ReadLine());

Console.WriteLine("Enter amount: ");


double money =
System.Convert.ToDouble(System.Console.ReadLine());

a1.Transfer(accountReceiver, money);

}
}
else
{
break;

}
} while (1 != 0);
}
}
}

BANK

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MID_ASSIGNMENT
{
class Bank
{

private string bankName;


public Account[] accounts;

public Bank(string bankName, int size)


{
this.bankName = bankName;
this.accounts = new Account[5];
}

public void Addaccount(Account account)


{
for (int i = 0; i < accounts.Length; i++)
{
if (accounts[i] == null)
{
accounts[i] = account;
break;
}
}

public void DeleteAccount(int accountno)


{
for (int i = 0; i < accounts.Length; i++)
{
if (accounts[i].accountNumber == accountno)
{
accounts[i] = null;
Console.WriteLine("\nAccount Delete:" + accountno);
break;
}

}
}
}

PROGRAM

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MID_ASSIGNMENT

class Program1
{
static void Main(string[] args)

{
Account a1 = new Account();
Address ob1 = new Address("11", "11/A", "Dhaka", "Bangladesh");
Bank b1 = new Bank("CHOWDHURY BANK", 3);

a1.accountName = "Indro";
a1.AccountNumber = 1;

do
{
Console.WriteLine("1.Account Delete\n 2.Deposit money\n 3.Withdraw
money\n 4.Transfer money\n");
Console.WriteLine("Enter Option: ");

int input = System.Convert.ToInt32(System.Console.ReadLine());

if (input != 0)
{
if (input == 1)
{
b1.Addaccount(a1);
Console.WriteLine("Address is: ");
ob1.ShowAddress();
Console.WriteLine("Do you want to delete your account ");
Console.WriteLine("Enter Account Number:");

if (input == 2)
{
Console.WriteLine("Deposit");
Console.WriteLine("Enter amount: ");
double Amount =
System.Convert.ToDouble(System.Console.ReadLine());

a1.Deposit(Amount);

if (input == 3)

Console.WriteLine("Withdraw");

Console.WriteLine("Enter amount: ");


double amount = System.Convert.ToDouble(System.Console.ReadLine());
a1.Withdraw(amount);

if (input == 4)
{
Console.WriteLine("Transfer");

Console.WriteLine("Enter the account: ");


int accountReceiver =
System.Convert.ToInt32(System.Console.ReadLine());

Console.WriteLine("Enteramount: ");
double money =
System.Convert.ToDouble(System.Console.ReadLine());

a1.Transfer(accountReceiver, money);

else
{
break;

}
}
} while (1 != 0);
}
}
}

You might also like