Click here to Skip to main content
16,004,647 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
CSS
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;
const double main_balance=10000;
double deposit(double amount);
double withdraw(double amount);

    int main()
    {
            string password;
            string account;
        cout<<"\t";cout<<"\t";
    cout<<"DEPOSIT AND WITHDRAW "<<endl;
    cout<<"................................................................................\n";
cout<<endl<<endl;
cout<<endl;
cout<<"\t\tEnter account number\t";
cin>>account;
    cout<<"\t";cout<<"\t";
    if(account.length()>=13)
    {

    cout<<"Enter password \t";
    cin>>password;
    cout<<endl;
    if(password.size()>=8)
    {
    cout<<"\t\tCHOOSE THE SERVICE FROM THE MENU "<<endl;
    cout<<endl;
    cout<<endl;
    char select;
    cout<<"A"<<" "<<"WITHDRAW MONEY";cout<<"\t";cout<<"\t";
    cout<<"B"<<" "<<"DEPOSIT MONEY";cout<<"\t";cout<<"\t";
    cout<<"C"<<" "<<"CHECK BALANCE\n";
    cout<<"\t\t\t\t";
    cin>>select;
    switch (select)
    {
        case 'A':
        case 'a':
            double money;
            double Amount;
            Amount=withdraw(money);
            break;
        case 'B':
        case 'b':
        double cash;
        double new_amount;
        new_amount=deposit(cash);cout<<"\t";
        cout<<"You have deposited \t"<<"Tsh"<<cash;
        cout<<endl;
        cout<<"\t";
        cout<<"The balance is \t"<<"Tsh"<<new_amount;

        break;
        case 'c':
        case 'C':
            cout<<"\t\t";
        cout<<"You are balance is "<<"Tsh "<<main_balance<<endl;
        break;
    default:

        cout<<"\t"<<"\t"<<"Invalid selection";
        cout<<endl;
        cout<<"\t\t";
    }

}

else
{
    cout<<"\t"<<"\t"<<"Your password is less than 8"<<endl;
}
}
else
{
    cout<<"Account number should contain 13 digits and above";
}
    return 0;
}

    double deposit(double amount)
    {
        cout<<"\t"<<"\t"<<"Enter the amount you to deposit\t";

        cin>>amount;
        cout<<endl;
        double new_balance;
        new_balance=main_balance+amount;
        return new_balance;
    }
    double withdraw(double amount)
    {
        double remain_balance;
        cout<<"\t"<<"\t"<<"Enter amount to withdraw from your account\t";
        cin>>amount;
        if(amount>=main_balance)
        {
            cout<<"\t"<<"\t"<<"You have insufficent balance to withdraw\t"<<"Tsh"<<amount;
            cout<<endl;
        }
        else
        {
            remain_balance=main_balance-amount;
            cout<<"\t"<<"\t"<<"You have withdrawn \t"<<amount<<endl;
            cout<<"\t"<<"\t"<<"Balance remained after to withraw\t"<<remain_balance<<endl;
            cout<<endl;

        return remain_balance;
        }
    }
Posted
Updated 19-Jan-14 6:58am
v3
Comments
Kornfeld Eliyahu Peter 19-Jan-14 6:08am    
I'm sorry to tell but this is no question!
It sounds like you want to take a programming course - in that case you came to the wrong place, try Google...
If you have a application and you stuck then show us where so we can help you out with...
Member 10533531 19-Jan-14 12:21pm    
Ok, i get you.
enhzflep 19-Jan-14 13:44pm    
I see that you've changed the question substantially from the original that I answered.
There's a different mind-set needed when switching from a linear program like this (that sits there actively waiting for user input) to one designed to respond to events (as is the case with javascript or windows GUI programming)

I suggest that you read the tutorial available from the forger, available here: theForger's Win32 API Programming Tutorial For what it's worth, you can expect to at least double the quantity of code required. A dialog-based app would be the shortest, quickest approach - as long as you use an .RC file. This will basically cut your main function down to about 3 lines, rather than the whole bunch I've used to define a new windows-class (not to be confused with the c++ notion of a class)

1 solution

While I agree that this is a poorly phrased (and researched!) question, there's an answer that comes straight from one of the project templates in my ide of choice, Code::Blocks. All I've done is add the button and the code to handle presses of this button.

It's been some 7 years or more since I last looked at DevC++ - I've no idea if it has a tchar.h, though I'd imagine it would. If it doesn't (and the code wont compile as a result), you can make a few fairly simple changes:

1. Remove the the code before #include <windows.h> and replace it with #define UNICODE 1
2. Remove all instances of _T(). Replace this with L.
I.e _T("You pressed button1.") becomes L"You pressed button1."

Finally, have a look into resource editors and dialog apps. I and many others use ResEdit to create the resource (.rc) file.

Note: You should link the following libraries: gdi32, user32, kernel32, comctl32

C++
#if defined(UNICODE) && !defined(_UNICODE)
    #define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
    #define UNICODE
#endif

#include <tchar.h>
#include <windows.h>

#define IDC_BUTTON1 1000

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");

int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           _T("Code::Blocks Template Windows App"),       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    CreateWindow( _T("Button"), _T("Button1"), WS_VISIBLE|WS_CHILD, 20,20, 75,23, hwnd, (HMENU)IDC_BUTTON1, hThisInstance, NULL);

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;

        case WM_COMMAND:
            {
                switch LOWORD(wParam)
                {
                case IDC_BUTTON1:
                    MessageBox(hwnd, _T("You pressed button1."), _T("Attention"), MB_ICONEXCLAMATION);
                    break;
                }
            }
            break;

        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900