Question
Create a Windows application that functions like a banking account register. Separate the business logic from the presentation layer. The graphical user interface should allow the user to input the account name, number, and balance. Provide textbox objects for withdrawals and deposits. A button should be available for clicking to process withdrawal and deposit transactions showing the new balance. THIS MUST BE C#
I HAVE A ERROR IN THE PROGRAM I RECEIVED FROM ANIMATEDPOTATO1546 I GET THE ERROR MESSAGE " CANNOT IMPLICTEDLY CONVERT STRING TO LONG OR FLOAT TO STRING AM I DOING SOMETHINT WRONG?
Explanation / Answer
class BankAccount { //attributes public string accountID; public string customerName; public int customerAge; public double balance; public const double DEFAULT_BALANCE = 500.00; //construct public BankAccount() { } public BankAccount(string anID, string aName, int anAge, double aBalance) { accountID = anID; customerName = aName; customerAge = anAge; balance = aBalance; if (aBalance == 0) { balance = DEFAULT_BALANCE; } else { balance = aBalance; } } public BankAccount(string anID, string aName, int anAge) { accountID = anID; customerName = aName; customerAge = anAge; balance = DEFAULT_BALANCE; } //accessors public void SetID(string anID) { accountID = anID; } public void SetName(string aName) { customerName = aName; } public void SetAge(int anAge) { customerAge = anAge; } public void SetBalance(double aBalance) { balance = aBalance; } public string GetID() { return accountID; } public string GetName() { return customerName; } public int GetAge() { return customerAge; } public double GetBalance() { return balance; } this is the form public partial class Form1 : Form { //ArrayList account = new ArrayList(); private List account = new List(); public Form1() { InitializeComponent(); } private void btnAddAccount_Click(object sender, EventArgs e) { BankAccount aBankAccount = new BankAccount(txtAccountID.Text, txtName.Text, int.Parse(txtAge.Text), double.Parse(txtBalance.Text)); account.Add(aBankAccount); AddToComboBox(); ClearText(); } private void AddToComboBox() { cboAccount.Items.Clear(); foreach (BankAccount person in account) { cboAccount.Items.Add(person.GetName()); //cboAccount.Items.Add(person); } } private void ClearText() { txtName.Clear(); txtAccountID.Clear(); txtBalance.Clear(); txtAge.Clear(); txtAccountID.Focus(); } private void cboAccount_SelectedIndexChanged(object sender, EventArgs e) { //txtNameTab2.Text = cboAccount.SelectedItem.ToString(); txtNameTab2.Text = account[cboAccount.SelectedIndex].customerName; txtAgeTab2.Text = account[cboAccount.SelectedIndex].customerAge.ToString(); txtAccountIDTab2.Text = account[cboAccount.SelectedIndex].accountID.ToString(); txtBalanceTab2.Text = account[cboAccount.SelectedIndex].balance.ToString(); } private void btnWithdraw_Click(object sender, EventArgs e) { } }