Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


about function

Modify the given program so that if allows the user to repeat the process for several transactions using the while loop. The program should call function DispTrans that tabulates the transaction information as tabulated below. The program provides for a maximum of 20 transactions, but allows the user to enter the actual number of transactions.
Outputs Tabulation Format:
TransType Beg.Balance DepositAmt WithdrawAmt End.Balance
_________ _________ _________ _________ _________
_________ _________ _________ _________ _________
Totals _________ _________ _________ _________

[color=Green]You will see an incomplete funtion definition at the end of the program.. can you give some suggestions about this given problem[/color]

using std:: cout;
using std:: cin;
using std:: endl;

using std:: setprecision;
using std:: setiosflags;
using std:: setw;

double PerformCompute( double Sbal, char transType, double TAmt);

int main()
{ double startingBalance, endingBalance, transAmount;
char tran;

cout<<"Enter the starting balance and press <Enter>:";

cout<<"Enter transaction type (D) deposit or (W) withdrawal"<<endl<<endl<< and press <Enter>";

endingBalance=PerformCompute(startingBalance, tran, transAmount);

cout<<setiosflags(ios::fixed|ios::showpoint|ios::right);<br />cout<<setprecision(2)<<endl;<br />cout<<"Starting Balance "<<startingBalance<<endl<<"Transaction ""<<transAmount<< " "<<tran <<endl;<br />cout<<"Ending Balance "<<endingBalance<<endl;<br />return 0;

double PerformCompute(double Sbal, char transType, double TAmt)
{double a,b;
if(transType=='D' || transType=='d')
return a;}
if (transType=='W' || transType=='w')
{b=Sbal -TAmt;
return b;}
[color=Blue]double DispTrans(
{int i=1,m;
while(i<=20)<br /> {if(transType=='D' || transType=='d')
{cout<<"Enter the transaction: "; <br /> cin>>m;}
if(transType=='W' || transType=='w')
{cout<<"Enter the transaction: ";<br /> cin>>m;}



  • LundinLundin Member Posts: 3,711
    I believe that your teacher want the while loop to be in main(). This means that transType must be passed to the function through a parameter.

    Also, the indention is horrible. You should make the program readable by doing something like this:

    [code]double DispTrans(char transType)
    int m;

    if(transType=='D' || transType=='d')
    cout<<"Enter the transaction: "; <br /> cin>>m;

    if(transType=='W' || transType=='w')
    cout<<"Enter the transaction: ";<br /> cin>>m;
Sign In or Register to comment.