本文介绍了帮我制作以下程序的Gui的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#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;
}
}
推荐答案
#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;
}
这篇关于帮我制作以下程序的Gui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!