我可以在下面获得项目帮助。我是初学者,我发现很难想出一个实际运行的代码 [英] Can I get help with my project below. I'm a beginner and I'm finding it very difficult to come up with a code that acctually runs

查看:52
本文介绍了我可以在下面获得项目帮助。我是初学者,我发现很难想出一个实际运行的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;

class account
{
    int accno;
    char name[50];
    int deposit;
    string type;

public:
       void create_account();
       void show_account();
       void modify();
       void dep(int);
       void draw(int);
       void report();
       int retacno();
       int retdeposit();
       string rettype();
};

   void account::create_account()
  {
   {
     ofstream accFile;
     accFile.open("new ac.txt");
     if(accFile.is_open() )
    {

     cout<<"Please enter the account number :\n"<<endl;
     cin>>accno;
     accFile << accno;

     cout<<"Enter the account holders name :\n"<<endl;
     cin>>name;
     accFile<<name;

     cout<<"Choose account type (Current/Savings):\n"<<endl;
     cin>>type;
     accFile<<type;
     cout<<"Enter initial deposit (>P250): \n"<<endl;
     cin>>deposit;
     accFile<<deposit
     accFile.close();
     }
     else
    cout<<"Unable to open file";
   }
     cout<<"\nDear Client, you account has been succesfully created";

   }


   void account::show_account()
   {
     cout<<"\n\n******************ACCOUNT DETAILS*********************\n";
     cout<<"\n\n--------------------------------------------------------------------\n";
     cout<<"ACCOUNT NAME     NAMES        ACCOUNT TYPE     ACCOOUNT BALANCE\n";
     cout<<"-----------------------------------------------------------------------\n";
     std::cin>>accno\t>>name\t>>type\t>>deposit>>;
     std::cout<<accno\t<<name\t<<type\t<<deposit<<;
   }

   void account::modify()
   {
 {   ofstream accFile;
     accFile.open("new ac.txt");
     if(accFile.is_open() )

     cout<<"\nAccount No.:" <<accno;
     cout<<"\nChange Account Holder's Name:";
     cin.getline(name,50);
     accFile<<accno;
     cout<<"\nChange Account Type:";
     cin>>type;
     accFile<<type;
     cout<<"\nAccount changes saved";
   }

    void account::dep(int a)
    {
        deposit+=a;
    }

    void account::draw(int a)
    {
        deposit-=a;
    }

    void account::report()
    {
        cout<<accno<<"\t"<<name<<"\t"<<deposit<<endl;
    }
    int account::retacno()
    {
        return accno;
    }
    int account::retdeposit()
    {
        return deposit;
    }

    string account::rettype()
    {
        return type;
    }

   void account :: create_account();	//function to write record in file
   void show_sp(int);	//function to display account details given by user
   void modify_acc(int);	//function to modify record of file
   void delete_acc(int);	//function to delete record of file
   void show_all();		//function to display all account details
   void deposit_withdraw(int, int); //

int main()
{

  char ch;
  int accnum;
  int option;
  do
  {
      system("cls");
      cout<<"\n\t WELCOME TO THE MAIN MENU";
      cout<<"***SELECT AN OPTION (1-8)***";
      cout<<"\n\t 1. NEW ACCOUNT";
      cout<<"\n\t 2. DEPOSITS";
      cout<<"\n\t  3. WITHDRAWALS";
      cout<<"\n\t  4. BALANCE ENQUIRY";
      cout<<"\n\t  5. SHOW ACCOUNT DETAILS";
      cout<<"\n\t  6. ACCOUNT CLOSURES";
      cout<<"\n\t  7. ACCOUNT MODIFICATIONS";
      cout<<"\n\t  8. EXIT";
      cin>>option;
      system("cls");

      switch(option)
    {
    case 1:
          void account:: reate_account();
           break;
    case 2:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           deposit_withdraw(accnum,1);
           break;
    case 3:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           deposit_withdraw(accnum,2);
           break;
    case 4:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           show_sp(accnum);
           break;
    case 5:
           show_all();
           break;
    case 6:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           delete_acc(accnum);
           break;
    case 7:
           cout<<"\n Enter Your Account Number:";
           cin>>accnum;
           modify_acc(accnum);
           break;
    case 8:
           cout<<"\n Thank You For Using Bank123";
           break;
    default :cout<<"\a";
  }
   cin.ignore();
   option = cin.get();
 }while(option != 8);

  return 0;

}





我的尝试:



我已经尝试了所有的东西,并且我不断在代码块中获得大约50个错误。请帮忙!!



What I have tried:

I've tried basically everything and I keep getting about 50 errors in codeblocks. Please help!!

推荐答案

建议:

- 使用程序员编辑器,它显示括号匹配并可以缩进代码

Notepad ++ Home [ ^ ]

UltraEdit:数百万信任的文本编辑器 [ ^ ]

- 缩进你的代码,它突出了代码结构。



C是C ++的祖先,读C的参考书不会有害,C ++的语法来自C语言。

C编程语言 - 维基百科,免费的百科全书 [ ^ ]

https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf [ ^ ]

http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf [ ^ ]





Advices:
- Use a programmer Editor, it show you parenthesis matching and can indent your code
Notepad++ Home[^]
Ultra the text editor trusted by millions[^]
- indent your code, it highlight the code structure.

C is the ancestor of C++, it will not harm to read the reference book of C, the syntax of C++ comes from C.
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]

In
 void account::create_account()
{
 {



删除 {,它应该删除一些错误。



[更新]


remove a { , it should remove a couple errors.

[Update]

case 1:
      void account:: reate_account();
       break;



这段代码表明你几乎不了解你的所作所为。

Nota:它是 create



建议:在做自己的项目之前跟随tutos。



[更新]

CodeBlocks是一个高级编辑器,功能丰富。

学习如何使用它们是一个好主意,这些功能可以帮到你。


This code show that you barely understand what you do.
Nota: it is create

Advice: follow tutos before doing your own projects.

[Update]
CodeBlocks is an advanced editor, feature rich.
It is a good idea to learn how to use them, those features are here to help you.


这篇关于我可以在下面获得项目帮助。我是初学者,我发现很难想出一个实际运行的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆