
01-Jun-2008, 16:41
|
|
New Member
|
|
Join Date: Dec 2007
Posts: 6
|
|
|
Help with small program
#include <iostream>
using namespace std; //introduces namespace std
class Account
{
private:
int acctNumber;
string acctName;
double acctBal;
public:
// 2 constructors
Account ()
{
acctNumber=0;
acctBal = 0;
acctName=" ";
}
Account (int a,string ac,double acc)
{
acctNumber=a;
acctBal = acc;
acctName = ac;
}
// sets
int setNum()
{
}
string setName()
{
}
double setBal()
{
}
// gets
int getNum()
{
return acctNumber;
}
string getName()
{
return acctName;
}
double getBal()
{
return acctBal;
}
};// end class
int main()
{
const int SIZE = 15;
Account bank[SIZE]= {Account (12345, "Smith", 1005.99),
Account (19822, "Lee", 20.21),
Account (18521, "Kim", 3061.77),
Account (85218, "Wall", 9855.33),
Account (85199, "Harry", 9077.88),
Account (91532, "Jess", 63112.99),
Account (43174, "Glee", 641.88),
Account (63173, "Corr", 841.55),
Account (23441, "Matt", 124.92),
Account (65185, "Card", 90.22),
Account (62188, "Kells", 529.77),
Account (32188, "Slyth", 863.22),
Account (90888, "Booth", 7422.88),
Account (52111, "Good", 321.99),
Account (87331, "Williams", 7317.21)};
cout <<"\tWelcome to Random Bank!";
cout <<"\n\tYou can make a deposit or withdraw ";
cout <<"\n\n\tPlease have your account number";
cout <<"\n\tor the name on the account ready\n";
// all of your code here
int choice;
cout << "Do you want to check account balance by name or account number?";
cout << endl;
cout << "1-Name";
cout << endl;
cout << "2-Account Number";
cout << endl;
cout << "3-Exit";
cout << endl;
cin >> choice;
string name;
int accNum;
if (choice == 1)
{
cout << "Enter your name: ";
cin >> name;
}
if (choice == 2)
{
cout << "Enter your account #: ";
cin >> accNum;
}
if (choice == 3)
{
"Good bye.";
}
// give user a choice of searching by acct number, name or quit
// make sure withdraw amount is not greater than balance
for(int i=0; i<SIZE; i++)
{
if(bank[i].getNum() == accNum && bank[i].getName() == name)
{
}
}
cout <<"Good Bye";
return 0;
How would I send the parts of the array to the class so I can compare name/number to check if its right so i can print account balance? then ask the person if he wants to withdraw or add(subtract if user wants to withdraw/add if the user wants to add).
|
|