在做任何事情之前退出基本的银行程序
Basic bank program exiting before doing anything
我尝试过调试,它似乎在int main
之后的大括号之前停止。有人能帮我们找到一个解决方案并解释为什么它不起作用吗。
#include <iostream>
#include <string>
using namespace std;
enum Menusystem // enum is a function used to convert the list of words below
// into numbers.
{
ShowMenu,
EnterName,
Account,
Deposit,
Withdraw,
Balance,
Exit
} menu;
int main() {
string customer; // declaring variables and their data types for the menu
// options.
string accounttype;
string name;
int credit;
int debit;
int currentbal;
bool exit = false; // declaring variable as boolean setting it to false so
// that when the loop gets to true it will break the loop.
int option = 0; // declares showmenu as a integer and sets value to 0 so that
// the menu will be displayed upon opening the program as in
// the code below the menu is displayed if option is equal to
// 0.
while (!Exit) // declares that if the exit button has not been pressed the
// application will stay open.
{
switch (menu) // initiates a switch statement which will allow the program
// to cycle through menu options depending on the menu option
// they select.
{
case ShowMenu:
cout << "[0] - Show menun" // displays menu options to user.
<< "[1] - Enter Full Namen"
<< "[2] - Enter Account Typen"
<< "[3] - Deposit Fundsn"
<< "[4] - Withdraw Fundsn"
<< "[5] - Display Balancen"
<< "[6] - Exit Programn";
cin >> option;
if (option == 0)
menu = ShowMenu;
else if (option == 1)
menu = EnterName;
else if (option == 2)
menu = Account;
else if (option == 3)
menu = Deposit;
else if (option == 4)
menu = Withdraw;
else if (option == 5)
menu = Balance;
else if (option == 6)
menu = Exit;
else
menu = ShowMenu; // default case is to show the menu.
break;
case EnterName:
cout << "Please enter your full name >n";
getline(cin, name);
menu = ShowMenu;
break;
case Account:
menu = ShowMenu;
break;
case Deposit:
menu = ShowMenu;
break;
case Withdraw:
menu = ShowMenu;
break;
case Balance:
menu = ShowMenu;
break;
case Exit:
menu = ShowMenu;
break;
default:
break;
}
}
}
更换
while (!Exit)
带
while (!exit)
此行是while (false)
循环
while(!Exit)
相关文章:
- boost::asio::io_service 在线程中,不会在应用程序退出时退出
- 当我选择大于 720 的矩阵大小时,程序退出并显示错误代码.可能是什么原因?
- thread_local静态类在程序退出时在无效地址处销毁
- OpenGL 应用程序退出,退出代码为 -1073741515 (0xC0000135)
- 程序退出后,将释放内存到系统
- 全局范围内的对象会导致程序退出时崩溃
- 不整洁的程序退出:MFC C
- 如果程序退出循环是goto已删除的本地变量
- Linux 阻止文件描述符在程序退出时关闭
- 为什么我的新分配指针会自动在程序退出上删除
- QFile在程序退出时保存文件,根本不会保存~500MB文件
- 类的静态实例无法在程序退出时正确处理资源删除
- 为什么全局或静态对象会导致程序退出时崩溃
- 由OpenCV 2.4.6创建的AVI文件在应用程序退出时并不总是有效
- C++DevIL函数ilLoadImage-程序退出,访问违规
- gdb程序退出了使用CMake的程序的代码01
- 问题5.1-QMessageBox错误?如果在QDialog隐藏时调用了QMessageBox,则程序退出(0)
- 多次调用函数会导致程序退出,并出现一个神秘的错误
- 如何在应用程序退出时诊断comptr版本中的异常
- C++-如何在程序退出时找到堆/堆栈损坏的源