Methods
Dec 7, 2012 at 8:10pm UTC
Hi I have a project where we need to create a bank account and its mostly with using methods. Im about 50% done but Im drawing a blank on this certain part. The bank account begins on a tab where the enter their personal info (name address etc.) and theres also a part where they have to enter the balance that theyre starting their account with. The starting balance is supposed to be "passed to the createAccount method. and a negative starting balance isnt allowed. Can anyone give me any guidance on how to do this? Thank you!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
// declare variables used by multiple methods
String^ fName;
String^ lName;
String^ address;
String^ deposit;
// String^ checking;
// String^ savings;
double bal;
String^ transact;
private : System::Void tabPage2_Click(System::Object^ sender, System::EventArgs^ e) {
}
private : System::Void tabPage4_Click(System::Object^ sender, System::EventArgs^ e) {
}
private : System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private : System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private : System::Void textBox3_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private : System::Void tabControl1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
}
private : System::Void btnSubmit_Click(System::Object^ sender, System::EventArgs^ e) {
/*
If Create Account, then
- fName = txtfName
- lName = txtlName
- address = txtAddress
- bal = txtBal
*/
if (tabControl1->SelectedTab == tabPage1)
// if (activeTab = "CreateAccount")
{
// If Create Account is submitted
fName = txtfName->Text;
lName = txtlName->Text;
address = txtAddress->Text;
Double::TryParse(txtBal->Text, bal);
//checking = cmbAccType->Text;
// savings = cmbAccType->Text;
txtfName->ReadOnly = true ;
txtlName->ReadOnly = true ;
txtAddress->ReadOnly = true ;
txtBal->ReadOnly = true ;
txtDeposit->ReadOnly = false ;
txtWDraw->ReadOnly = false ;
} if (tabControl1->SelectedTab == tabPage5)
{
lblfName->Text = fName;
lbllName->Text = lName;
lblAddress->Text = address;
//lblAccType->Text =
//lblBal->Text = ToString(bal);
}
{
// If Account Details is submitted
}
//Transactions
//txtTran->Text = transact;
txtDeposit->Text = deposit;
//txtSum->Text = sum.ToString();
//Balance account detail
lblBal->Text = +
//closing account, enable and disable txtboxes and clear data
if (tabControl1->SelectedTab == tabPage4)
{
MessageBox::Show("Account has been closed!!" );
txtfName->ReadOnly = false ;
txtlName->ReadOnly = false ;
txtAddress->ReadOnly = false ;
txtBal->ReadOnly = false ;
txtDeposit->ReadOnly = true ;
txtWDraw->ReadOnly = true ;
txtfName->Text = "" ;
txtlName->Text = "" ;
txtAddress->Text = "" ;
txtBal->Text = "" ;
}
}
private : System::Void tabPage1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private : System::Void tabPage5_Click_1(System::Object^ sender, System::EventArgs^ e) {
}
};
}
Dec 7, 2012 at 10:29pm UTC
First, your code is very messy and i did not bother reading it. But from your description, try something like this.
1 2 3 4 5
do
{
//prompt use for input
std::cin >> balance; // or how ever you are getting input
}while ( balance >= 0 )
You should probably display a message to the user too like "Cannot have a negative balance." or something.
Topic archived. No new replies allowed.