试图建立银行管理系统,但有错误
Trying to make an bank management System but having errors
我想完成的事情是应用程序方法的功能,但从代码中得到许多错误,我不完全理解并试图解决,但一无所获。
#include <conio.h>
#include <stdio.h>
#include <iostream>
using namespace std;
class bank
{
char name [100],add[100],y;
int balance, amount;
public:
void open_account();
void deposite_money();
void withdraw_money();
void display_account();
};
void bank:open_account()
{
cout << "Enter your full name: ";
cin.ignore();
cin.getline(name,100);
cout << "What type of account you want to open savings (s) or current (c)";
cin >> y;
cout << "Enter amount of deposite: ";
cin >> balance;
cout << "Your account is created ";
}
void bank:deposite_money()
{
int a ;
cout << "Enter how much money you want to deposit: ";
cin >> a;
balance += a;
cout << "Your total deposit amountn ";
}
void bank:display_account()
{
cout << "Enter the name: "<<name<<endl;
cout << "Enter your address: "<<add<<endl;
cout << "Type of account that you open: "<<y<<endl;
cout << "Amount you deposite: "<<balance<<endl;
}
void bank:withdraw_money()
{
cout << "Withdraw: ";
cout << "Enter the amount of withdrawing";
cin >> amount;
balance = balance - amount;
cout << "Now your total amount left is" <<balance;
}
int main()
{
int ch,x,n;
bank obj;
do
{
cout <<"01")open accountn";
cout <<"02")deposite moneyn";
cout <<"03")withdraw moneyn";
cout <<"04")display accountn";
cout <<"05")Exitn";
cout << "Please select from the options above";
cin>>ch;
switch(ch)
{
case 1:"01")open accountn";
obj.open_account();
break;
case 2:"02")deposite moneyn";
obj.deposite_money();
break;
case 3:"03")withdraw moneyn";
obj.withdraw_money();
break;
case 4:"04")display accountn";
obj.display_account();
break;
case 5:
if(ch == 5)
{
cout << "Exit";
}
default:
cout<< "This is not the proper exit please try again";
}
cout << "ndo you want to select the next step then please press : yn";
cout << " If you want to exit then press : N";
x=getch();
if(x == 'y' || x == 'Y');
cout<< "Exit";
}
while (x == 'y' || x == 'Y');
getch();
return 0;
}
我遇到的错误是
error stray ''
error missing terminating character
error found ':' in nested name specifier
expected ; before ')' token
这些是通常出现在日志上的错误,并且在不同的行中重复了几次,请帮助我,以便我可以完成此应用程序 我从制作中学到了很多东西,并期待在学校开学前构建更多 非常感谢关于我下一步应该做什么的任何帮助和建议,并非常欢迎我从这次经历中学习
顺便说一句,我正在使用c ++,并且正在尝试构建一些项目,以便下次提供任何建议吗?在出现此错误后如何提高自己,以及我接下来应该练习什么,就像你们建议我的下一个项目一样
看这里:
#include <stdio.h>
#include <iostream>
using namespace std;
class bank
{
char name [100],add[100],y;
int balance, amount;
public:
void open_account();
void deposite_money();
void withdraw_money();
void display_account();
};
void bank::open_account()//: missing
{
cout << "Enter your full name: ";
cin.ignore();
cin.getline(name,100);
cout << "What type of account you want to open savings (s) or current (c)";
cin >> y;
cout << "Enter amount of deposite: ";
cin >> balance;
cout << "Your account is created ";
}
void bank::deposite_money()//: missing
{
int a ;
cout << "Enter how much money you want to deposit: ";
cin >> a;
balance += a;
cout << "Your total deposit amountn ";
}
void bank::display_account()//: missing
{
cout << "Enter the name: "<<name<<endl;
cout << "Enter your address: "<<add<<endl;
cout << "Type of account that you open: "<<y<<endl;
cout << "Amount you deposite: "<<balance<<endl;
}
void bank::withdraw_money()//: missing
{
cout << "Withdraw: ";
cout << "Enter the amount of withdrawing";
cin >> amount;
balance = balance - amount;
cout << "Now your total amount left is" <<balance;
}
int main()
{
int ch,x,n;
bank obj;
do
{
cout <<"01)open accountn";//Delete " after Number
cout <<"02)deposite moneyn";
cout <<"03)withdraw moneyn";
cout <<"04)display accountn";
cout <<"05)Exitn";
cout << "Please select from the options above";
cin>>ch;
switch(ch)
{
case 1:"01)open accountn";//Delete " after Number
obj.open_account();
break;
case 2:"02)deposite moneyn";
obj.deposite_money();
break;
case 3:"03)withdraw moneyn";
obj.withdraw_money();
break;
case 4:"04)display accountn";
obj.display_account();
break;
case 5:
if(ch == 5)
{
cout << "Exit";
}
default:
cout<< "This is not the proper exit please try again";
}
cout << "ndo you want to select the next step then please press : yn";
cout << " If you want to exit then press : N";
cin >> x;
if(x == 'y' || x == 'Y');
cout<< "Exit";
}
while (x == 'y' || x == 'Y');
}
也不要在标头中使用命名空间,并且总体上学习更好的样式。这是 80 年代的 C,混入了C++。使用不是在数组中内置的容器,使用 iostream,总体上会得到一本好C++书。
相关文章:
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 我的代码中有错误,未声明的标识符
- 超市管理系统的类别之间应该是什么关系?
- C++ LeetCode #377 的 DP 解决方案中,此代码是否有错误?
- 试图建立银行管理系统,但有错误
- 我试图创建临时对象的方式有错误吗
- 我的随机生成器是否不工作,或者我决定人/骨架是否击中对手的方式是否有错误
- 我在OpenCV中有错误的"approxPolyDP(ROI_Vertices, ROI_Poly, 1.0, true)"
- 我在这个 C++ 代码上有错误吗?
- 是视觉C++优化器错误还是我的代码中有错误?
- 为什么一个简单的C++程序会有错误的结果?是 #define 引起的吗?
- 对此有错误
- C :数据文件有错误:预期的无限制ID
- 一个带有参数的程序,为什么此程序有错误的答案
- 仅使用boost.datetime在Windows上有错误
- 使用向量循环时,是否有错误
- Microsoft Visual Studio发现我所有的CUDA设备端函数都有错误
- C++ Mingw32 创建进程() 失败,错误代码 2:系统找不到指定的文件
- 继承默认构造函数在 gcc 中失败并在 clang 中工作,哪个有错误?
- 学生成绩管理系统 在C++中,表达式必须具有指向对象类型的指针