473,516 Members | 2,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

my problem here is INQUIRY and WITHDRAW.. what should i do? cn u pls help me?

1 New Member
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4.  
  5. void newAccount();
  6. void Inquiry();
  7. void Deposit();
  8. void Withdraw();
  9. void List();
  10. int exitProgram();
  11. void menu();
  12. using namespace std;
  13. string name[10];
  14. int accountID[10], newAccountID;
  15. int pin[10], newPIN;
  16. double balance[10];
  17. double amountDeposited=0.0;
  18. int counter =0;
  19. int main(){
  20.     system ("cls");
  21.     menu();
  22.     getch();
  23.     return 0;
  24. }
  25.  
  26. void menu(){
  27.      char answer;
  28.      system("cls");
  29.      cout<<"\t\tWelcome to World Bank, Insert your Card in ATMmachine\n";
  30.      cout<<"\n";
  31.      cout<<"\t\t\tHello,Please enter your user name:\t\n";
  32.      cout<<"\n";
  33.      cout<<"[N]*New Account \n";
  34.      cout<<"[D]*Deposit \n";
  35.      cout<<"[i]*Inquiry \n";
  36.      cout<<"[W]*Withdraw \n";
  37.      cout<<"[L]*List all accounts\n";
  38.      cout<<"[E]*Exit Program \n";
  39.      cout<<"\nPlease Select : ";
  40.      cin>> answer;
  41.      if (answer == 'n' || answer == 'N'){
  42.         newAccount();
  43.      }else if (answer == 'd' || answer == 'D'){
  44.         Deposit();
  45.      }else if (answer == 'I' || answer == 'i'){
  46.         Inquiry();
  47.      }else if (answer == 'w' || answer == 'W'){
  48.         Withdraw();
  49.      }else if (answer == 'e' || answer == 'E'){
  50.         exitProgram();
  51.          }else if (answer == 'l' || answer == 'L'){
  52.         List();
  53.      }else{
  54.         cout <<"Invalid";
  55.      }     
  56. }
  57.  
  58. void newAccount(){
  59.      system ("cls");
  60.      cout<<"\nAccount ID      : ";
  61.      cin>>accountID[counter]; 
  62.      cout<<"PIN             : ";
  63.      cin>>pin[counter];
  64.      cout<<"Initial Deposit : ";
  65.      cin>>amountDeposited;
  66.      balance[counter] = balance[counter] + amountDeposited;
  67.      counter++;
  68.      menu();
  69. }
  70.  
  71. void Deposit(){
  72.      system("cls");
  73.      cout<<"\nAccount ID      : ";
  74.      cin>>newAccountID;
  75.      for (int y=0; y<counter; y++){
  76.          if (newAccountID == accountID[y]){
  77.             cout<<"PIN             : ";
  78.             cin>>newPIN;
  79.             if (newPIN == pin[y]){
  80.                 cout<<"How much to be deposited ? ";
  81.                 cin>>amountDeposited;
  82.                 balance[y] = balance[y] + amountDeposited;
  83.                 cout<<"Your current balance is : "<<balance[y];
  84.                 cout<<"\n Press any key to continue...";
  85.                 getch();
  86.             }else{
  87.                 cout <<"Invalid\n";
  88.                 getch();  
  89.                 Deposit();  
  90.             }      
  91.          }
  92.  
  93.      }
  94.      menu();
  95. }
  96.  
  97. void Inquiry(){
  98.      system("cls");
  99.      cout<<"\nAccount ID      : ";
  100.      cin>>newAccountID;
  101.      cout<<"PIN             : ";
  102.      cin>>newPIN;
  103.      if (newAccountID == accountID[counter] && pin[counter] == newPIN){
  104.         cout<<"Your current balance is : " << balance;  
  105.      }else{
  106.           cout<<"Invalid account, Press Enter to continue \n"; 
  107.           getch();
  108.           Inquiry();
  109.      }
  110.  
  111.      getch();
  112.      menu();
  113. }
  114.  
  115. void Withdraw(){
  116.      system("cls");
  117.      int amount;
  118.      cout<<"Account ID  :";
  119.      cin >>newAccountID;
  120.      cout<<"PIN         :";
  121.      cin>>newPIN;
  122.      if (newAccountID == accountID[counter] && pin[counter] == newPIN){
  123.         cout<<"Enter Amount   :";
  124.         cin >>amount;
  125.         if (amount > balance[counter]){
  126.            cout<<"Insuficient Balance \n";
  127.            cout<<"Please enter a valid amount";
  128.            getch();
  129.            Withdraw();
  130.         }else{
  131.             cout<<"Processing....\n\n";
  132.             balance[counter] = balance[counter] - amount;
  133.             cout<<"Press Enter to continue";
  134.         }
  135.      }else{
  136.           cout << "Invalid account, Press Enter to continue \n"; 
  137.           getch();
  138.           Withdraw();
  139.      }
  140.  
  141.      getch();
  142.      menu();
  143.  
  144. }
  145. void List(){
  146.        system("cls");
  147.        cout<<"AccountID\t"<<"PIN"<<"\t"<<"Balance"<<"\n";
  148.        for (int x=0; x<counter; x++){
  149.          cout << accountID[x]<< "\t"<<"\t";
  150.          cout << pin[x]<<"\t";
  151.          cout << balance[x];
  152.          cout << "\n";
  153.  
  154.      }
  155.      getch();
  156.      menu();
  157. }
  158.  
  159. int exitProgram(){
  160.      cout << "\n\n \t\t thankyooooou! :) ";
  161.      return 0;
  162. }
Mar 3 '14 #1
2 1115
weaknessforcats
9,208 Recognized Expert Moderator Expert
What is your problem exactly?
Mar 3 '14 #2
donbock
2,426 Recognized Expert Top Contributor
I notice that Deposit(), Inquiry(), and Withdraw() are recursive; and the recursion is potentially unbounded. I think you want to loop back to near the start of these functions (rather than invoke another instance) when faced with invalid input.
Mar 3 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
2053
by: Berislav Lopac | last post by:
Imagine three options: a) There is an XML file. A PHP5 script loads it and puts it into a DOM document object. Then, given an input string, a function looks via XPath for a node with that name (or possibly value of an attribute) and returns the node's content. b) There is a text file containing a serialized array. PHP script opens it and...
0
1643
by: Miki Tebeka | last post by:
Hello All, The following script "hangs" on win32 system: from Tkinter import * from tkSimpleDialog import askstring root = Tk() root.withdraw() # <<< Problem here askstring("Yap", "What's up?")
4
2326
by: Martin Magnusson | last post by:
I'm getting segmentation faults when trying to fix a memory leak in my program. The problem is related to lists of pointers which get passed around between objects. Here is a description of how the code works: I have a stack consisting of nodes and arguments, much like a function execution stack. In this example there are only three nodes...
0
1174
by: Joe Van Meer | last post by:
Hi all, I have a question regarding data relations within a data set. Say I have 3 tables named CLIENT, BOOKING and EMPLOYEE and I wanted to relate the first two tables (CLIENT AND BOOKING) via a clientid and relate the second set of tables (BOOKING AND EMPLOYEE) using an employeeid. My problem arises when there a re no records in one of...
4
1868
by: M.Posseth | last post by:
Hello I have this code that generates a xml string Dim sw As New System.IO.StringWriter Dim objXML As New XmlTextWriter(sw) Dim strXml As String With objXML
4
1166
by: segue | last post by:
Just Curious.
1
2005
by: Anthony J. Biondo Jr. | last post by:
Hi Everyone: I was wondering if it is common practice to use some sort of messaging (MSMQ, WebSphere MQ) with web services. I understand the need for messaging for insert / update transactions, but do you think using messaging for inquiry transactions is overkill? thanks, Anthony
7
1611
by: Louly | last post by:
Hi everybody, I have "cmb A" and "cmb B", "cmb A" lists tables names and "cmb B" should list the fields of the table name selected in "cmb A". I've tried to implement it but I it doesn't work! Any help would be appreciated. Thanks for your time. Lou
37
1797
by: nolo contendere | last post by:
I've recently begun playing with prototype.js as well as scriptaculous, and found both very helpful in developing web pages with lots of pop. Modal boxes, SlideUp/Down, calendars, etc. I've also recently ramped up my lurking and participation in this newsgroup. There are some who advocate using prototype, and others who are adamantly...
25
2747
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the object itself is a subprocess, not a "popen". It seems that it would be more accurate to just name the class Subprocess, can anyone explain why this...
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3267
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.