Im working on some home work and have been beating my head against the wall for 3 days trying to figure this out here is the code ill explain what im trying to do under the code
Code:
// Bankapp chapter 7 case 2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
// Declaration Section
class Bank
{
private:
int accountNum;
int accountTerm;
double accountBal;
string output;
const static int ANNUAL_RATE;
public:
void displayAccountNum();
void setAccountData(int, int, double);
void computeInterest();
int getAccountNum();
double getAccountBal();
int getAccountTerm();
};
const int Bank::ANNUAL_RATE = 3;
void Bank::setAccountData(int num, int term, double bal)
{
accountNum = num;
accountTerm = term;
accountBal = bal;
}
void Bank::displayAccountNum()
{
cout << accountNum << " Account has $"
<< accountBal
<< " and will gain interest for "
<< accountTerm << "yrs" << endl;
}
int main()
{
Bank aBank;
int accountNum = 0;
int accountTerm = 0;
//double accountBal = 0;
const int TIMES = 10;
double accountBal = 0.0;
for (int x=0; x < TIMES; ++x)
{
cout << "Enter " << "#" << x+1 << " account term from 1 to 10 years" << endl; // Account terms prompt
cin >> accountTerm;
while (accountTerm < 1 || accountTerm > 10)
{
cout << "Error! Please try again" << endl;
cout << "Enter " << "#" << x+1 << " first account term from 1 to 10 years" << endl;
cin >> accountTerm;
}
cout << "Enter " << "#" << x+1 << " Account number(Between 1000 and 9999(0000 to quit)) at a time: " << endl; // Prompt for an account number
cin >> accountNum;
//aBank[count].setAccountData(accountNum);
while (accountNum < 1000 || accountNum > 9999)
{
cout << "Error! Please try again." << endl;
cout << "Enter " << "#" << x+1 << " Account number(Between 1000 and 9999(0000 to quit)): " << endl;
cin >> accountNum;
}
cout << "Enter " << "#" << x+1 << " Account Balance(Can not be less than 0 or more than 100000): " << endl; // Prompt for an account balance
cin >> accountBal;
while (accountBal <= 0 || accountBal > 100000)
{
cout << "Error! Please try again." << endl;
cout << "Enter " << "#" << x+1 << " first Account Balance(Can not be less than 0 or more than 100000): " << endl;
cin >> accountBal;
}
aBank.setAccountData(accountNum, accountTerm, accountBal);
aBank.displayAccountNum();
}
system("pause");
return 0;
}
What the book wants is a class just like i have but i need to to store the data in an array to store 10 accounts with there balances and the term of the account... im sure im over thinking it and its probably no different then doing a normal array im just getting to mad any help would be greatly appreciated