stallion5000
asked on
my array, that is tied to a class, is now filled with numbers, how do I total up whats in the array thats tied to a class?
class header
#include<iostream>
#include<string>
using namespace std;
#ifndef TRANSACTION
#define TRANSACTION
class transaction
{
private:
string transactionType;
string transactionAmountd, transactionAmountw;
public:
void settransactionType(string type);
string gettransactionType();
void settransactionAmountd(stri ng amount);
string gettransactionAmountd();
void settransactionAmountw(stri ng amount);
string gettransactionAmountw();
};
#endif
methods
#include "transaction.h"
void transaction::settransactio nType(stri ng type)
{
transactionType = type;
}
string transaction::gettransactio nType()
{
return transactionType;
}
void transaction::settransactio nAmountd(s tring amount)
{
transactionAmountd = amount;
}
string transaction::gettransactio nAmountd()
{
return transactionAmountd;
}
void transaction::settransactio nAmountw(s tring amount)
{
transactionAmountw = amount;
}
string transaction::gettransactio nAmountw()
{
return transactionAmountw;
}
the functions, where my problem is.
void entertransactions(transact ion transaction[],int const &items )
{
string stuff;
char con = 'y';
while((con !='n')&&(con !='N'))
{
for (int index = 0; index <=items; ++index)
{
cout << "Enter Transaction Type, ex. Enter D for Deposit or W for Withdrawals";
getline(cin,stuff);
transaction[index].settran sactionTyp e(stuff);
if (transaction[index].gettra nsactionTy pe() == "D" || transaction[index].gettran sactionTyp e() == "d")
{
cout << "Enter deposit amount";
getline(cin,stuff);
transaction[index].settran sactionAmo untd(stuff );
}
else
{
if (transaction[index].gettra nsactionTy pe() == "W" || transaction[index].gettran sactionTyp e() == "w")
{
cout << "Enter withdrawal amount";
getline(cin,stuff);
transaction[index].settran sactionAmo untw(stuff );
}
else
{
cout << "Error, Please Enter a D for Deposit or W for Withdrawals";
}}
index++;}
cout << "Enter Y to enter another transaction or No to go back to menue";
cin >> con;}
}
void displayAcount(transaction, items) (ok so I filled my array in the above part,
now I need to total it up what I put in here transaction[index].settran sactionAmo untd(stuff );)
{
string stuff;
double totalD = 0;
double totalW = 0;
for(int i=0; i==items; totalD += ????? maybe something like this transaction[index].settran sactionAmo untd( );
#include<iostream>
#include<string>
using namespace std;
#ifndef TRANSACTION
#define TRANSACTION
class transaction
{
private:
string transactionType;
string transactionAmountd, transactionAmountw;
public:
void settransactionType(string type);
string gettransactionType();
void settransactionAmountd(stri
string gettransactionAmountd();
void settransactionAmountw(stri
string gettransactionAmountw();
};
#endif
methods
#include "transaction.h"
void transaction::settransactio
{
transactionType = type;
}
string transaction::gettransactio
{
return transactionType;
}
void transaction::settransactio
{
transactionAmountd = amount;
}
string transaction::gettransactio
{
return transactionAmountd;
}
void transaction::settransactio
{
transactionAmountw = amount;
}
string transaction::gettransactio
{
return transactionAmountw;
}
the functions, where my problem is.
void entertransactions(transact
{
string stuff;
char con = 'y';
while((con !='n')&&(con !='N'))
{
for (int index = 0; index <=items; ++index)
{
cout << "Enter Transaction Type, ex. Enter D for Deposit or W for Withdrawals";
getline(cin,stuff);
transaction[index].settran
if (transaction[index].gettra
{
cout << "Enter deposit amount";
getline(cin,stuff);
transaction[index].settran
}
else
{
if (transaction[index].gettra
{
cout << "Enter withdrawal amount";
getline(cin,stuff);
transaction[index].settran
}
else
{
cout << "Error, Please Enter a D for Deposit or W for Withdrawals";
}}
index++;}
cout << "Enter Y to enter another transaction or No to go back to menue";
cin >> con;}
}
void displayAcount(transaction,
now I need to total it up what I put in here transaction[index].settran
{
string stuff;
double totalD = 0;
double totalW = 0;
for(int i=0; i==items; totalD += ????? maybe something like this transaction[index].settran
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.