using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace BankAccountsProject
string address {get; set;}
string zipcode {get; set;}
public Person(string Name, string Address,string ZipCode,string Phone,string City)
Console.WriteLine("Person name: " + name);
Console.WriteLine("Person lives in: " + city);
Console.WriteLine("Person address: " + address);
Console.WriteLine("Person zipcode: " + zipcode);
Console.WriteLine("Person phone: " + phone);
public float balance {get; set;}
public int noOfDeposits {get; set;}
public int noOfWithdrawls {get; set;}
public float annualInterestRate {get; set;}
public float monthlyServiceCharges {get; set;}
public Person customer {get; set;}
public Account(float Balance, float AnnualInterestRate, Person cust)
annualInterestRate = AnnualInterestRate;
public void deposit(float amount)
public void withdraw(float amount)
float MonthlyInterestRate = (annualInterestRate/12);
float MonthlyInterest = balance * MonthlyInterestRate;
balance += MonthlyInterest;
public virtual void monthlyProc()
balance -= monthlyServiceCharges;
monthlyServiceCharges = 0;
public class SavingsAccount : Account
public SavingsAccount(float Balance, float AnnualInterestRate, Person cust) : base(Balance, AnnualInterestRate, cust)
public void withdraw(float amount)
Console.WriteLine("Sorry, not enough balance");
public void deposit(float amount)
if(status == 0 && (balance+amount>15)){
public override void monthlyProc()
monthlyServiceCharges += (noOfWithdrawls-4);
if((balance-monthlyServiceCharges) < 15){
public class CheckingAccount : Account{
public void withdraw(float amount){
if((balance-amount) < 0){
monthlyServiceCharges+=15;
public void monthlyProc(){
monthlyServiceCharges += 5;
float extra = (float)(noOfWithdrawls*0.10);
monthlyServiceCharges += extra;
public CheckingAccount(float Balance, float AnnualInterestRate, Person cust) : base(Balance, AnnualInterestRate, cust)
public static float[] selectionSort(float[] arr, int n) {
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
public static void printer(Account acc, float[] strt, float[] end, int i){
Console.WriteLine("Customer Details: ");
Console.WriteLine("Start balance: "+strt[i]);
Console.WriteLine("Withdrawls: "+acc.noOfWithdrawls);
Console.WriteLine("Deposits: "+acc.noOfDeposits);
Console.WriteLine("Service charges: "+acc.monthlyServiceCharges);
Console.WriteLine("Ending balance: "+end[i]);
public static void Main(string[] args)
float[] strtbalance = new float[5];
float[] endbalance = new float[5];
for(int i = 0; i < 2; i++){
Console.WriteLine("\n\n\nPlease Enter Customer detail");
Console.WriteLine("Enter customer name:\n");
string n = Console.ReadLine();
Console.WriteLine("Enter customer address:\n");
string a = Console.ReadLine();
Console.WriteLine("Enter customer zipcode:\n");
string z = Console.ReadLine();
Console.WriteLine("Enter customer city:\n");
string c = Console.ReadLine();
Console.WriteLine("Enter customer phone number:\n");
string p = Console.ReadLine();
Person cust = new Person(n,a,z,p,c);
Console.WriteLine("Enter "+n+"'s balance:");
float b = float.Parse(Console.ReadLine());
Console.WriteLine("Enter annual interest rate:\n");
float ai = float.Parse(Console.ReadLine());
Console.WriteLine("Savings Account");
SavingsAccount acc = new SavingsAccount(b, ai, cust);
Console.WriteLine("Enter amount to deposit:\n");
float dpt = float.Parse(Console.ReadLine());
Console.WriteLine("Enter amount to withdraw:\n");
float wdr = float.Parse(Console.ReadLine());
Console.WriteLine("Enter amount to withdraw again:\n");
float wdr2 = float.Parse(Console.ReadLine());
Console.WriteLine("Enter amount to deposit:\n");
float dpt2 = float.Parse(Console.ReadLine());
Console.WriteLine("Ending balance: "+acc.balance);
endbalance[i] = acc.balance;
printer(acc, strtbalance, endbalance,i);
Console.WriteLine("Checking Account");
CheckingAccount acc = new CheckingAccount(b, ai, cust);
Console.WriteLine("Enter amount to deposit:\n");
float dpt = float.Parse(Console.ReadLine());
Console.WriteLine("Enter amount to withdraw:\n");
float wdr = float.Parse(Console.ReadLine());
Console.WriteLine("Enter amount to withdraw again:\n");
float wdr2 = float.Parse(Console.ReadLine());
Console.WriteLine("Enter amount to deposit:\n");
float dpt2 = float.Parse(Console.ReadLine());
Console.WriteLine("Ending balance: "+acc.balance);
endbalance[i] = acc.balance;
printer(acc, strtbalance, endbalance,i);
string tbe = (endbalance.Sum().ToString());
string tbs = (strtbalance.Sum().ToString());
string mbe = (endbalance.Min().ToString());
string mbs = (strtbalance.Min().ToString());
string mxbe = (endbalance.Max().ToString());
string mxbs = (strtbalance.Max().ToString());
string abs = (strtbalance.Average().ToString());
string slctsrt = selectionSort(endbalance, endbalance.Length).ToString();
float arrmin = endbalance.Min();
string idx = Array.BinarySearch(endbalance, arrmin).ToString();
string writetofile = "Total balance ending: "+tbe+"\n\n";
writetofile += "Total balance starting: "+tbs+"\n\n";
writetofile += "Min balance starting: "+mbs+"\n\n";
writetofile += "Max balance starting: "+mxbs+"\n\n";
writetofile += "Min balance ending: "+mbe+"\n\n";
writetofile += "Max balance ending: "+mxbe+"\n\n";
writetofile += "Average balance starting: "+abs+"\n\n";
writetofile += "Selection sort: "+slctsrt+"\n\n";
writetofile += "Location of min balance found using binary search: "+idx+"\n\n";
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(@"C:\Users\Zafar\Desktop\AD\AccountDetails.txt"))
file.WriteLine(writetofile);