Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Function call

Write a program that determines the ending balance given the starting balance, a transaction amount and the transaction type.

[code]
#include
using std:: cout;
using std:: cin;
using std:: endl;

#include
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>:";
cin>>startingBalance;

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

endingBalance=PerformCompute(startingBalance, tran, transAmount);

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

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

WHAT WILL BE TYPED HERE??!!

}
[/code]


Actually, Im still figuring out what will be the missing arguments in the function definition.. I did not fully understand the problem.. there is something to withdraw and deposit..

can you give suggestions, specifically, those who have understanding in accounting problems..<<<Thanks>>

Comments

  • phillcahillphillcahill Posts: 18Member
    This answers the question.

    Most of the code i used is yours but changed a few bits. The W or D Needs validation to imrove quality and gain you marks but you can do that your self. Don't forget to comment your code.

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

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

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

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

    cout<<"Enter transaction amount <Enter>:";
    cin>>transAmount;

    endingBalance=PerformCompute(startingBalance, tran, transAmount);

    cout<<"Starting Balance "<<startingBalance<<endl<<"Transaction "<<transAmount<< " "<<tran <<endl;
    cout<<"Ending Balance "<<endingBalance<<endl;

    getch();
    return 0;
    }

    double PerformCompute(double Sbal, char transType, double TAmt)
    {
    if(transType=='D')
    {
    return Sbal += TAmt;
    }
    else
    {
    return Sbal -= TAmt;
    }
    }

Sign In or Register to comment.