473,769 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My Program is compiling, but it wont stop running. Can you please help me?

2 New Member
// Program to create new accounts, perform deposits, withdrawals, and bank
//inquiries
#include<iostre am>
#include<fstrea m>
using namespace std;
void menu();
int read_accts(int [], double [], int);
void withdrawal(int [], double [], int);
void deposit(int [], double [], int);
int new_acct(int [], double [], int);
void balance(int [], double[], int);
int main()
{
char answer;
int a, num_elems, max_elems;
int acctnum[6] = {123456,781912, 238427,581493,9 41357,842364};
double balance[6] = {500000,100,654 00,500,1000,20} ;

max_elems = read_accts (acctnum, balance, 100);
num_elems = read_accts (acctnum, balance, 100);

while (num_elems <=6){
read_accts(acct num, balance, max_elems);
if (answer == 'W') withdrawal(acct num, balance, num_elems);
if (answer == 'D') deposit(acctnum , balance, num_elems);
}

do {
menu();
cout << "Which banking transaction would you like to use? Enter Q to quit";
cout << " the transaction " << endl;
cin >> answer;

}while ((answer != 'Q') && (answer != 'q'));

system ("pause");
return 0;

}

// Function: read_accts
// Input:
// account numbers and their current balances
// Process:
// reads in the account number and its balance
// Output:
// prints the account number and its balance

//Function to read in the account numbers and their balances
int read_accts (int acctnumarray [], double balancearray [], int maxelems)
{
int a, elemcount = 0;
double balance;
for (a = 0; a <=6; a++){

// declare and open input file
// fstream infile("c:\\Dev-Cpp\\bankprogin put.txt");
// ifstream infile(“con”); //un-comment for debugging

cout << "The account number is " << acctnumarray[a];
cout << "and its balance is " << balancearray[a] << endl;

}

return elemcount;


}

// Function: menu
// Input:
// none
// Process:
// creates a menu for the user
// Output:
// A menu is printed

// Function to print the menu
void menu()
{
cout << " Menu of Transactions" << endl;
cout << " W = withdrawal" << endl;
cout << " D = deposit" << endl;
cout << " N = new account" << endl;
cout << " B = balance" << endl;
cout << " Q = quit" << endl;
return;
}

// Function: Withdrawal
// Input:
// none
// Process:
// determines amount of money that the user wants to take out
// Output:
// the amount of money to be withdrawn

// Function to make a withdrawal
void withdrawal (int acctnumarray [], double balancearray [], int numelems)
{
int with = 0;
int acctnum, a;

cout << "Enter your account number: - end with EOF" << endl;
cin >> acctnum;
for (a = 0; a <= numelems; a++);
if (acctnum == acctnumarray[a])
{
cout << "How much money would you like to withdraw?" << endl;
cin >> with;
}
else if (acctnum != acctnumarray[a])
{
cout << "This is an invalid account number." << endl;
}

if (with <= balancearray[a])
{
cout << "Your account does not have a sufficient amounts of funds";
cout << "to proceed with this transaction." << endl;
}

return;
}

// Function: Deposit
// Input:
// none
// Process:
// determines amount of money that the user wants to take out
// Output:
// the amount of money to be withdrawn

//Function to make a deposit
void deposit (int acctnumarray [], double balancearray [], int numelems)
{
int dep = 0;
int acctnum, a;

cout << "Enter your account number:" << endl;
cin >> acctnum;
for (a = 0; a <= numelems; a++);{
cout << "How much money would you like to deposit?" << endl;
cin >> dep;
if (acctnum != acctnumarray[a]);
cout << "This account does not exist." << endl;

}
return;
}

// Function: balance
// Input:
// none
// Process:
// determines amount of money that the user has left in their account
// Output:
// the amount of money to be withdrawn

//Function to tell you how much money is in your account
//void balance (int acctnumarray [], double balancearray [], int numelems)
//{
//}
Nov 29 '06 #1
1 2261
MariyaGel
7 New Member
Im not exactly sure if this is what you wanted since im new at this but i got the program to stop being in an endless loop and you can fix up the rest from here.

Here it is:

#include<iostre am>
#include<fstrea m>
using namespace std;
void menu();
int read_accts(int [], double [], int);
void withdrawal(int [], double [], int);
void deposit(int [], double [], int);
int new_acct(int [], double [], int);
void balance(int [], double[], int);
int main()
{
char answer;
int a, num_elems, max_elems;
int acctnum[6] = {123456,781912, 238427,581493,9 41357,842364};
double balance[6] = {500000,100,654 00,500,1000,20} ;

max_elems = read_accts (acctnum, balance, 100);
num_elems = read_accts (acctnum, balance, 100);

do {
menu();
cout << "Which banking transaction would you like to use? Enter Q to quit";
cout << " the transaction " << endl;
cin >> answer;
if (answer == 'W') withdrawal(acct num, balance, num_elems);
if (answer == 'D') deposit(acctnum , balance, num_elems);

}while ((answer != 'Q') && (answer != 'q'));

system ("pause");
return 0;

}

// Function: read_accts
// Input:
// account numbers and their current balances
// Process:
// reads in the account number and its balance
// Output:
// prints the account number and its balance

//Function to read in the account numbers and their balances
int read_accts (int acctnumarray [], double balancearray [], int maxelems)
{
int a, elemcount = 0;
double balance;
for (a = 0; a <=6; a++){

// declare and open input file
// fstream infile("c:\\Dev-Cpp\\bankprogin put.txt");
// ifstream infile(“con”); //un-comment for debugging

cout << "The account number is " << acctnumarray[a];
cout << "and its balance is " << balancearray[a] << endl;

}

return elemcount;


}

// Function: menu
// Input:
// none
// Process:
// creates a menu for the user
// Output:
// A menu is printed

// Function to print the menu
void menu()
{
cout << " Menu of Transactions" << endl;
cout << " W = withdrawal" << endl;
cout << " D = deposit" << endl;
cout << " N = new account" << endl;
cout << " B = balance" << endl;
cout << " Q = quit" << endl;
return;
}

// Function: Withdrawal
// Input:
// none
// Process:
// determines amount of money that the user wants to take out
// Output:
// the amount of money to be withdrawn

// Function to make a withdrawal
void withdrawal (int acctnumarray [], double balancearray [], int numelems)
{
int with = 0;
int acctnum, a;

cout << "Enter your account number: - end with EOF" << endl;
cin >> acctnum;
for (a = 0; a <= numelems; a++);
if (acctnum == acctnumarray[a])
{
cout << "How much money would you like to withdraw?" << endl;
cin >> with;
}
else if (acctnum != acctnumarray[a])
{
cout << "This is an invalid account number." << endl;
}

if (with <= balancearray[a])
{
cout << "Your account does not have a sufficient amounts of funds";
cout << "to proceed with this transaction." << endl;
}

return;
}

// Function: Deposit
// Input:
// none
// Process:
// determines amount of money that the user wants to take out
// Output:
// the amount of money to be withdrawn

//Function to make a deposit
void deposit (int acctnumarray [], double balancearray [], int numelems)
{
int dep = 0;
int acctnum, a;

cout << "Enter your account number:" << endl;
cin >> acctnum;
for (a = 0; a <= numelems; a++);{
cout << "How much money would you like to deposit?" << endl;
cin >> dep;
if (acctnum != acctnumarray[a]);
cout << "This account does not exist." << endl;

}
return;
}

// Function: balance
// Input:
// none
// Process:
// determines amount of money that the user has left in their account
// Output:
// the amount of money to be withdrawn

//Function to tell you how much money is in your account
//void balance (int acctnumarray [], double balancearray [], int numelems)
//{
//}
Nov 30 '06 #2

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

Similar topics

1
3003
by: Will Stuyvesant | last post by:
I never used the popen or popen2 libraries but it is my understanding that they can capture the output of console based programs. Is it also possible to send keystrokes to console base programs? I would like to program a Python program that can play for instance the tty version of nethack 3.4.3 on Windows, simulating a human player: for nethack it would not be possible to know if a human or a computer program is playing it. It is a...
10
2495
by: An Ony | last post by:
Hi, I made a console program in C# and it works for me. Now I sent it to someone else and he can't run it. Program error or something. His OS is in Swedish. What could this be? Does he have to have the .NET FrameWork installed to run ..NET programs? I sent it to him once as exe and another time as an ace, so I don't think it got messed up during transfer. Any thoughts?
1
1731
by: Mike Hutton | last post by:
I need some help. I am trying to set up our development environment so as to make life easy for my fellow developers (none of whom have used ASP.NET or VS.NET before). We are developing our intranet which will comprise basic content with a number of small data-driven ASP.NET applications. I need to keep things simple, so I need to avoid stuff which needs too much in-depth knowledge to work.
17
2036
by: so many sites so little time | last post by:
all right so the script is pretty simple it goes it retrives what the id of the post is and it lets you edit it well no it doesnt. now if you go to www.kirewire.com/pp2/index/php you will see a number 1 that is the value of collumn home_id which is set to auto increment ect ect but this script which gets the id of home_id of a row and lets you edit it does not work for somereason...
10
7662
by: ycg0771 | last post by:
I'm trying to modify the following program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. It seems that the more I read into this, the more confused I get. Any help will be greatly apreciated. Here is my latest code... // Payroll program that...
6
5437
by: aureao4 | last post by:
I'm new to Java and programming. I'm trying to code a payroll program and continue getting errors. The program worked last week, this week I have to add set, get and a class. I've written the class but when I compile the program I get 13 errors. Can anyone assist me with this? Thank you! Errors I get: C:\Java>javac *.java Payroll3.java:18: illegal start of type while ( !exit ) ^ Payroll3.java:18: <identifier>...
20
10644
by: Boki Digtal | last post by:
Hi All, How to limit the c# program can only run one instance at the same time ? Thank you! Best regards, Boki.
62
3166
by: Ajinkya | last post by:
As "spawnl" executes an exe through C code., similarly how can we compile a C program through another C program (on Windows platform) ?
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10045
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5298
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.