Hi i need some help for my program which is banking system, i could not run it , i am a beginner

Jun 27, 2018 at 6:45am
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include<iostream.h>
#include<conio.h>

#define OPEN 1
#define DEPOSIT 2
#define WITHDRAW 3
#define BALANCE 4
#define CLOSEACCOUNT 5
#define EXIT 6

int main()
{
//////////////////////Init
char name[64];
bool openBank = false;
double balance = 0;
double d = 0; // custom input
int choice;

bool bQuit = false;
//////////////////////Start
while(bQuit == false)
{
system("cls");

cout <<"\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n";
cout <<"\t\tBANKING SYSTEM"; if(openBank){ cout << "\tName : \"" << name << "\" Balance : " << balance; }cout <<"\n";
cout <<"\t[1] Open an Account\n";
cout <<"\t[2] Deposit Transaction\n";
cout <<"\t[3] Withdrawal Transaction\n";
cout <<"\t[4] Balance Inquiry\n";
cout <<"\t[5] Close Account\n";
cout <<"\t[6] Exit\n\n";
cout <<"\tPlease choose: "; cin >> choice;

cout <<"\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n";

Case :

if(choice != OPEN && openBank == false && choice !=CLOSEACCOUNT && choice != EXIT)
{cout <<"\tPlease, open the account first\n";choice = OPEN;}

//////////////////////Command
switch(choice)
{
//////////////////////////////////////////////////////////////////////////////////////////////////////
case OPEN :
if(openBank == false){
cout <<"\tAccount name : ";cin >> name;openBank = true;balance = 0;
cout <<"\tWell done " << name << "! The Bank System has been opened !!!\n";
}
else
{cout <<"\tYou'll need to close the account first !\n";choice = CLOSEACCOUNT;goto Case;}

break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case DEPOSIT : d = 0;

cout <<"\tEnter the amount to deposit (min 500) : ";
cin >> d;
while(d < 500)
{

cout <<"\tYou enter is below the minimum deposit. Please enter again.\n\n";
cin >> d;

}
balance = balance + d;
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case WITHDRAW :

cout <<"\tEnter the amout to withdraw : ";
cin >> d;
while(d > balance || d<=0 || balance - d < 500){
cout <<"\t Please enter again.\n\n";
cin>>d;
}
balance = balance - d;
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case BALANCE :
cout<<"\tYour current balance is: "<<balance<<"\n";
cout <<"Please enter to go back to the main menu. ";getch();
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case CLOSEACCOUNT :
if(openBank == false)cout <<"The bank is closed. No need to close now.\n\n";
else
{
cout <<"Please [1] to delete Account and [0] to go back to main menu: "; cin >> choice;
if(choice == 1){name[0] = 0;openBank = false;}
}
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case EXIT : bQuit = true; break;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////End case commands
}
//////////////////////End Bank loop
return 0;
}
//////////////////////End program...
Jun 27, 2018 at 7:10am
What error messages did you get ?
What compiler do you use ?
Jun 27, 2018 at 9:04am
Have you simply copied this awful awful code from here?

http://www.cplusplus.com/forum/general/84789/2/

It's awful code. No modern C++ compiler will know what to do with it. It uses C++ code from before 1998, when C++ wasn't formalised and it was basically just whatever you could trick a compiler into accepting.

Do not try to learn from such awful, awful code...

Unless you're stuck using a compiler from 20 years ago? Let me guess, Turbo C++ of some kind? What is the deal with people being taught just plain incorrect C++, badly, using old old tools, when there are free modern tools available?
Last edited on Jun 27, 2018 at 9:10am
Jun 29, 2018 at 5:50am
yeah its little complicated code , it was posted before, can you help me with simple banking system code ?
Last edited on Jun 29, 2018 at 2:16pm
Jun 29, 2018 at 11:39am
I have made some changes - nothing fance. Any C++98 capable compiler should compile it.
Try to run it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include<iostream>
#include<string>

using std::cout;
using std::cin;
using std::string;

const int OPEN = 1;
const int DEPOSIT = 2;
const int WITHDRAW = 3;
const int BALANCE = 4;
const int CLOSEACCOUNT = 5;
const int EXIT = 6;

int main()
{
  string name;
  bool openBank = false;
  double balance = 0;
  double d = 0; // custom input
  int choice;

  bool bQuit = false;

  while (bQuit == false)
  {
    cout << "\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n";
    cout << "\t\tBANKING SYSTEM"; 
    if (openBank) 
    { 
      cout << "\tName : " << name << "\n";
      cout <<"Balance : " << balance; 
    }
    cout << "\n";
    cout << "\t[1] Open an Account\n";
    cout << "\t[2] Deposit Transaction\n";
    cout << "\t[3] Withdrawal Transaction\n";
    cout << "\t[4] Balance Inquiry\n";
    cout << "\t[5] Close Account\n";
    cout << "\t[6] Exit\n\n";

    cout << "\tPlease choose: "; cin >> choice;

    cout << "\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n";



    if (choice != OPEN && openBank == false && choice != CLOSEACCOUNT && choice != EXIT)
    {
      cout << "\tPlease, open the account first\n"; choice = OPEN;
    }

    //////////////////////Command
    switch (choice)
    {
    case OPEN:
      if (openBank == false)
      {
        cout << "\tAccount name : "; cin >> name; openBank = true; balance = 0;
        cout << "\tWell done " << name << "! The Bank System has been opened !!!\n";
      }
      else
      {
        cout << "\tYou'll need to close the account first !\n"; choice = CLOSEACCOUNT;
      }
      break;

    case DEPOSIT:
      d = 0;
      cout << "\tEnter the amount to deposit (min 500) : ";
      cin >> d;
      while (d < 500)
      {
        cout << "\tYou enter is below the minimum deposit. Please enter again.\n\n";
        cin >> d;

      }
      balance = balance + d;
      break;
    case WITHDRAW:
      cout << "\tEnter the amout to withdraw : ";
      cin >> d;
      while (d > balance || d <= 0 || balance - d < 500) {
        cout << "\t Please enter again.\n\n";
        cin >> d;
      }
      balance = balance - d;
      break;
    case BALANCE:
      cout << "\tYour current balance is: " << balance << "\n";
      cout << "Please enter to go back to the main menu. "; 
      cin.get();
      break;
    case CLOSEACCOUNT:
      if (openBank == false)cout << "The bank is closed. No need to close now.\n\n";
      else
      {
        cout << "Please [1] to delete Account and [0] to go back to main menu: "; cin >> choice;
        if (choice == 1) { name[0] = 0; openBank = false; }
      }
      break;
    case EXIT: 
      bQuit = true; 
      break;
    }
  }
  return 0;
}


There is a logic error in the withdraw functionality that need to be fixed.
Jun 29, 2018 at 1:10pm
@tommy251 I'm curious... why are you copying code that was posted 5 years ago, that you know to be awful?
Jun 29, 2018 at 1:13pm
My guess; the homework being set hasn't changed for 5 years.
Jun 29, 2018 at 1:29pm
That was my guess, too. But I would have thought that if one was going to cheat on one's homework by copying someone else's work, one would at least have the sense to copy code that wasn't awful.

*Sigh* that's the problem with the world these days - the cheaters have no standards any more.
Jun 29, 2018 at 2:01pm
thank you , it runs online but coudn't deposit , it shows enter again ,,,,,,,,

**i am in the 10th grade and i am taking CS course and our teacher said we can submit any codes as a beginner project, so i came up with ATM or banking system code ideas , and was looking online ,ofcourse i will put this website/forum as a reference, /he said so/ not Plagiarism or copying
Last edited on Jun 29, 2018 at 2:18pm
Jun 29, 2018 at 2:26pm
Well, if you are going to copy code, then why not go big!!!!

Copy something like a Super Nintendo emulator.

https://github.com/snes9xgit/snes9x
Jun 29, 2018 at 3:06pm
jesus Millennials !!! i am just 14 ,
Jun 29, 2018 at 4:21pm
@tommy251 did a brief run check of Thomas' few changes and Deposit seems to be fine. If you made further changes you should post your latest as another reply, with [code] [/code] tags

Also, if you're going to copy, be ready to defend every single line. Be ready to explain your reasoning behind why the line is there, including type(s) chosen, logic benefits, and, to be honest, I'd be curious to see your defense of some of the indentation.
Jul 2, 2018 at 2:59am
i mean withdraw functionality not working i don't know to fix that
Jul 2, 2018 at 6:54am
Withdraw functionality is quite simple.
First you check if the balance is >= withdraw amount. If it is then subtract the amount from the balance otherwise show an error msg.
Jul 3, 2018 at 6:39am
oh thank you so much
Topic archived. No new replies allowed.