Question is
Write a modular program (function) for problem given below.
This program will let you enter the initial balance for the month, followed by a series of transactions. There is no limit on the number of transactions the program can process. A transaction takes the form of two input values: a single letter, followed by a float number. If the letter is:
C, then the number is the amount for a check (withdrawal)
D, then the number is the amount for a deposit
E, this is a sentinel value to signal the end of input
For each transaction entered, the program will echo-print the transaction data, the current balance for the account ( not including deductions for service charges ), the service charge for the transaction, and the total accumulated service charges for all transactions. After the end sentinel is processed, the program will print the current balance, total service charges, and the closing balance (balance after deducting service charges ).
Service charges are:
• Check fee : $0.15 for each check (withdrawal )
• Deposit fee : $0.10 for each deposit
• Low balance fee : if the balance drops below $500.00 at any point during the month, a service charge of $5.00 is assessed for the month ( one time only ).
• If the balance drops below $50.00, the program prints a warning message, but no fee is charged.
• Overdrawn balance fee : if the balance becomes negative, an additional service charge of $10.00 must be assessed for each check until the balance becomes positive again.

Solution:

#include <iostream.h>
#define CF 0.15
#define DF 0.10
#define LB 5.00
#define OD 10.00
float result(char transaction, float balance, float amount);
void main ()

float b, a, i;
char t;
cout<<"\nWelcome To Mike's Banking";
cout<<"\nChoose C for withdrawal";
cout<<"\nChose D for deposit";
cout<<"\nChoose E for end of input";
cout<<"\n\nWhat's Your Current Balance";
cin>>b;
cout<<"\nWhat Transaction You Want To Do: ";
for (i=1; i>0; i++)
{
cin>>t;
}
cout<<"\nWhat's The Amount You Want To Involve: ";
cin>>a;
if (t == 'C')
{
cout<<"\nYour Current Account Balance Is: "<<b;
cout<<"\nYou Have Chosen To Withdraw Money";
cout<<"\nYour Check Fee Is $0.15";
for (i=0; i<1; i++);
{
if (b < 500)
cout<<"There's A Low Balance Fee $For 500.00";
}
for (i=0; i<1; i++);
{
if (b < 50)
cout<<"Your Balance Is Below 50 Dollars";
}
}
else if (t == 'D')
{
cout<<"\nYour Current Account Balance Is: "<<b;
cout<<"\nYou Have Chosen To Deposit Money";
cout<<"\nYour Deposit Fee Is $0.10";
for (i=0; i<1; i++);
{
if (b < 0)
cout<<"There's An Overdrawn balance fee for $10.00";
}
for (i=0; i<1; i++);
{
if (b < 50)
cout<<"Your Balance Is Below 50 Dollars";
}
}
else if (t == 'E')
{
cout<<"\nYou Have Chosen to end the transaction";
cout<<"\nYour Initial Balance Was: "<<b;
cout<<"\nYour Total Service Charges Is: ";
cout<<"\nYour End Balance Is: "<<result;
}
else
cout<<"Choose A Choice man!";
}
float result(char transaction, float balance, float amount)
{
char t;
float i, b, a;
if (t == 'C')
{
for (i=0;i<1;i++);
{
if ( b < 0 && b < 500)
{
result = b + a - 0.15 - 5;
return result;
}
else if ( b < 500)
{
result = b + a - 5;
return result;
}
else if (b < 0)
{
result = b + a - 0.15;
return result;
}
}
}
if (t == 'D')
{
for (i=0;i<1;i++);
{
if ( b < 0 && b < 500)
{
result = b + a - 0.10 - 5;
return;
}
else if ( b < 500)
{
result = b + a - 5;
return;
}
else if (b < 0)
{
result = b + a - 0.10;
return;
}
}
}
}

There 12 errors that I cant solve it....

Recommended Answers

All 2 Replies

There 12 errors that I cant solve it....

Post the errors, we are not mind readers.

#ifndef HEADER_IOSTREAM_H
#define HEADER_IOSTREAM_H

#include <iostream>
using namespace std; 
#endif
// included the top so as to be able to use
// iostream.h
#define CF 0.15
#define DF 0.10
#define LB 5.00
#define OD 10.00


float L_balance = 0;// To store the end balance
float T_service = 0; // To store the total service charge
int main ()
{

    float b, a;
    char t;
    cout<<"\nWelcome To Mike's Banking";
    cout<<"\nChoose C for withdrawal";
    cout<<"\nChose D for deposit";
    cout<<"\nChoose E for end of input";
    cout<<"\n\nWhat's Your Current Balance: ";
    cin>>b;
    while (true)
    {
        cout<<"\nWhat Transaction Do You Want To Do: ";
        /* creating infinit loop
        for (i=0; i>2; i++)
        {*/
            cin>>t;
        //}

        if (t == 'C')
        {

            cout<<"\nYour Current Account Balance Is: "<<(b - L_balance - T_service);
            cout<<"\nYou Have Chosen To Withdraw Money";
            if (b < 0)
            {
                cout<<"There's An Overdrawn balance fee for $10.00\n";
            }

            if (b < 500)
                cout<<"There's A Low Balance Fee $For 500.00\n";

            if (b < 50)
                cout<<"Your Balance Is Below 50 Dollars\n";

            cout<<"\nWhat's The Amount You Want To Withdraw: ";
            cin>>a;
            L_balance += a;
            cout<<"\nYour Check Fee Is $0.15\n";
            T_service += 0.15;
        }
        else if (t == 'D')
        {
            cout<<"\nYour Current Account Balance Is: "<<(b - L_balance - T_service);
            cout<<"\nYou Have Chosen To Deposit Money";
            cout<<"\nWhat's The Amount You Want To Deposit: ";
            cin>>a;
            cout<<"\nYour Deposit Fee Is $0.10\n";

            T_service += .10;

            if (b < 50)
                cout<<"Your Balance Is Below 50 Dollars\n";

        }
        else if (t == 'E')
        {

            cout<<"\nYou Have Chosen to end the transaction";
            cout<<"\nYour Initial Balance Was: "<<b;
            b = b - L_balance - T_service;
            cout<<"\nYour Total Service Charges Is: "<<T_service;
            cout<<"\nYour End Balance Is: "<<b;
            cout<<"\n";
            break;
        }
        else
        cout<<"Choose A Choice man!";
    }

    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.