-1

The things that i would like to accomplish is the functions of methods of the applications but getting many errors from the code which i don't completely understand and try to solve but came up with nothing.

#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 amount\n ";
}
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 account\n";
        cout <<"02")deposite money\n";
        cout <<"03")withdraw money\n";
        cout <<"04")display account\n";
        cout <<"05")Exit\n";
        cout << "Please select from the options above";
        cin>>ch;

        switch(ch)
        {
            case 1:"01")open account\n";
            obj.open_account();
            break;
            case 2:"02")deposite money\n";
            obj.deposite_money();
            break;
            case 3:"03")withdraw money\n";
            obj.withdraw_money();
            break;
            case 4:"04")display account\n";
            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 : y\n";
        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;
}

The errors that i am getting are

error stray '\'
error missing terminating character
error found ':' in nested name specifier
expected ; before ')' token

These are the errors that usually appears on the logs and has repeated a few times in different lines please help me so that i can finish this application i have learned a lot from making it and is looking forward to build more before my school starts Any help and suggestions on what i should do next is appreciated and advices on what i should do next will greatly be welcome for me to learn from this experience

Im using c++ btw and am trying to build some projects any advice for next time? How can improve myself after this errors and what should i next practice on like a next project that you guys would suggest me

Scheff's Cat
  • 19,528
  • 6
  • 28
  • 56
  • Please, use bold mark-up with care and, at best, don't. Otherwise, this may be recognized as "shouting" and may appear rude. – Scheff's Cat May 14 '20 at 09:29
  • 1
    Btw. it looks like you just dumped your complete code into the question. Please, reduce the code as much as possible to form a [mcve] just to make your error reproducible. Additionally, it couldn't hurt to remark the line (e.g. by a comment) for which the compiler complaint is emitted. If in doubt, please, take the [tour] and read [ask]. (Every experienced member of this community will see that you did not yet.) ;-) – Scheff's Cat May 14 '20 at 09:31
  • In what lines you get the errors 3 of those seems easy to fix – dt170 May 14 '20 at 09:32
  • Btw. please, have a look at the syntax highlighting for e.g. `cout <<"01")open account\n";`. It already tells you that something is wrong with your constant string (aka C string literal). – Scheff's Cat May 14 '20 at 09:37
  • The lines are from 17 to 76 – EncryptedBoy May 14 '20 at 09:38
  • 1
    My bad i will read the how to ask – EncryptedBoy May 14 '20 at 09:38

1 Answers1

0

See here:

#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 amount\n ";
}
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 account\n";//Delete " after Number
        cout <<"02)deposite money\n";
        cout <<"03)withdraw money\n";
        cout <<"04)display account\n";
        cout <<"05)Exit\n";
        cout << "Please select from the options above";
        cin>>ch;

        switch(ch)
        {
            case 1:"01)open account\n";//Delete " after Number
                obj.open_account();
                break;
            case 2:"02)deposite money\n";
                obj.deposite_money();
                break;
            case 3:"03)withdraw money\n";
                obj.withdraw_money();
                break;
            case 4:"04)display account\n";
                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 : y\n";
        cout << " If you want to exit then press : N";
        cin >> x;
        if(x == 'y' || x == 'Y');
        cout<< "Exit";
    }
    while (x == 'y' || x == 'Y');
}

Also don't use using namespace in headers, and in overall learn a better style. This is 80s C with C++ mixed in. Use containers not built in arrays, use iostream and overall get a good C++ book.

Superlokkus
  • 4,731
  • 1
  • 25
  • 57
  • I dont have books actually are there any free books that are available in the internet? – EncryptedBoy May 14 '20 at 09:45
  • https://faculty.psau.edu.sa/filedownload/doc-8-pdf-95bf5763251f491480a0c1e5b76a16d8-original.pdf and https://en.cppreference.com/ Don't forget to accept the answer if it helped you – Superlokkus May 14 '20 at 09:46
  • 1
    @JoshNathanJosol Also, not free but all definitely worth the price: https://stackoverflow.com/q/388242/12448530 – Object object May 14 '20 at 10:02