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
|
#include <iostream>
using namespace std;
class SavingsAccount
{
public:
//SavingsAccount();
//SavingsAccount(int dollars, int cents);
void deposit(int dollars, int cents);
void withdraw(int dollars, int cents);
void total(int dollars, int cents);
void set(int dollars, int cents);
void convert(int dollars, int cents);
private:
double D_balance;
double W_balance;
double total_money;
};
int main()
{
SavingsAccount bank1, bank2;
int dollars, cents;
bank1.set(30, 65);//setting bank1 to have initial money as I call upon the void set function above
int anwser;
cout << "Would you like to 1.Deposit or 2.Withdraw?";
cin >> anwser;
if (anwser == 1)
{
cout << "Enter in how much you want to deposit in dollars:";
cin >> dollars;
cout << "Enter in how much you want to deposit in cent:";
cin >> cents;
if (dollars < 0 || cents < 0)
{
cerr << "Invalid!" << endl;
exit(1);
}
bank1.deposit(dollars, cents);//should call upon the seprate deposit funtction below
}
else if (anwser == 2)
{
cout << "Enter in how much you want to withdraw in dollars:";
cin >> dollars;
cout << "Enter in how much you want to withdraw in cents:";
cin >> cents;
if (dollars < 0 || cents < 0)
{
cerr << "Invalid!" << endl;
exit(1);
}
bank1.withdraw(dollars, cents);
}
else
{
cerr << "Error! Input not valid!" << endl;
exit(1);
}
}
void SavingsAccount::set(int dollars, int cents)
{
}
void SavingsAccount::convert(int dollars, int cents)
{
dollars = cents / 100;
cents = dollars - cents;
}
void SavingsAccount::deposit(int dollars, int cents)
{
D_balance = dollars + cents * .01;
}
void SavingsAccount::withdraw(int dollars, int cents)
{
W_balance = dollars + cents * .01;
}
void SavingsAccount::total(int dollars, int cents)
{
total_money = D_balance - W_balance;
}
|