试图建立银行管理系统,但有错误

Trying to make an bank management System but having errors

本文关键字:有错误 管理系统 建立      更新时间:2023-10-16

我想完成的事情是应用程序方法的功能,但从代码中得到许多错误,我不完全理解并试图解决,但一无所获。

#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++书。