OtherPapers.com - Other Term Papers and Free Essays
Search

C# Biggest Number

Essay by   •  August 14, 2016  •  Course Note  •  2,901 Words (12 Pages)  •  1,335 Views

Essay Preview: C# Biggest Number

Report this essay
Page 1 of 12

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Prac_01

{

class Program

{

static void Main(string[] args)

{

//• An array must be used to manage the bank accounts of 4 different people.

BankAccounts allAccounts = new BankAccounts(4);

while (true)

{

Menu();

char response = char.Parse(Console.ReadLine());

switch (response)

{

case '1': for (int i = 0; i < 4; i++)

{

AddBankAccount(allAccounts);

}

break;

case '2': Deposit(allAccounts);

break;

case '3': WithDraw(allAccounts);

break;

case '4': ChangeDet(allAccounts);

break;

case '5': DisplayAll(allAccounts);

break;

case 'x':

case 'X': Console.WriteLine("Exiting..........");

Console.ReadLine();

return;

default: Console.WriteLine("Where did you see that option, choose from the MENU or go sleep!..........");

Console.WriteLine("Press ENTER if you're sober and choose again...");

Console.ReadLine();

break;

}

}

}

static void AddBankAccount(BankAccounts database)

{

Console.Write("Enter client name: ");

string client = Console.ReadLine();

Console.WriteLine();

BankAccount newAcc = new BankAccount(client);

database.AddAccount(newAcc);

Console.WriteLine("Bank account created for " + newAcc.GetName());

Console.WriteLine("Press ENTER to continue.....");

Console.ReadLine();

}

static void Deposit(BankAccounts database)

{

Console.Write("Enter Account Holder name: "); //assumption is the names are the unique ID of a given BankAccount

string client = Console.ReadLine();

Console.WriteLine();

int pos = database.FindAccount(client);

if (pos != -1)

{

BankAccount curAcc = database.GetAccount(pos);

double curBal, nuBal;

curBal = curAcc.GetBal();

Console.Write("Enter amount to deposit: ");

double amt = double.Parse(Console.ReadLine());

Console.WriteLine();

nuBal = curBal + amt;

curAcc.setBal(nuBal);

Console.WriteLine("Deposit Successful!");

Console.WriteLine("Press ENTER to continue.....");

Console.ReadLine();

}

else

{

Console.WriteLine("Client not found!");

Console.WriteLine("Press ENTER to continue.....");

Console.ReadLine();

}

}

//Strong Copy + Paste Game :)

static void WithDraw(BankAccounts database)

{

Console.Write("Enter Account Holder name: "); //assumption is the names are the unique ID of a given BankAccount

...

...

Download as:   txt (7.3 Kb)   pdf (49.7 Kb)   docx (10.3 Kb)  
Continue for 11 more pages »
Only available on OtherPapers.com