I have some problems with creating functions. I think I did everything right, but I can't figure out the problem. i will post the code. I know some of it might be incorrect now, but I will fix that later. I just need help with the functions.
Code:
//Bank Account Application
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
addAccount()
{
float addInput;
cout<<"Enter the amount you wish to add to your account: ";
cin>>addInput;
return addInput;
}
subAccount()
{
float subInput;
cout<<"Enter the amount you wish to deduct from your account: ";
cin>>subInput;
return subInput;
}
interestAccount()
{
float interest;
cout<<"Enter your monthly interest rate: ";
cin>>interest;
float interestAdd;
interestAdd=interest/accountBalance[numAccounts]*100;
return interestAdd;
}
displayAccount()
{
for(int i;i<numAccounts;i++)
{
cout<<"Information for account number "<<accountNumber[numAccounts]<<".";
cout<<"Starting balance: "<<startBalance[numAccounts]<<"\n";
cout<<"Currect balance: "<<accountBalance[numAccounts]<<"\n";
}
}
main()
{
//program description
cout<<"Description.";
int maxAccounts=10;
for(int numAccounts=0;numAccounts<maxAccounts;numAccounts++)
{
char choice;
cout<<"Enter 'N' for new account or 'V' to view account information.";
cin>>choice;
if(choice==v||choice==V)
{
//view account info
}
else
{
int accountNumber[numAccounts];
cout<<"Enter account number: ";
cin>>accountNumber[numAccounts];
float startBalance[numAccounts];
cout<<"Enter your currect account balance: ";
cin>>startBalance[numAccounts];
accountBalance[numAccounts]=startBalance[numAccounts];
for(;;)
{
char choice2;
cout<<"Enter 'D' to deposit or add money, 'W' to withdraw or deduct, 'I' to calculate interest, or 'X' to return to main menu.";
cin>>choice2;
if(choice2==x||choice2==X)
{
//return to main menu loop
break;
}
else
{
switch(choice2)
{
case d:
case D:
//call function addAccount()
accountBalance[numAccounts]=accountBalance[numAccounts]+addAccount();
break;
case w:
case W:
//call function subAccount()
accountBalance[numAccounts]=accountBalance[numAccounts]-subAccount();
break;
case i:
case I:
//call function interestAccount()
accountBalance[numAccounts]=accountBalance[numAccounts]+interestAccount();
break;
default:
cout<<"You did not enter a 'D', 'W', or an 'I'.";
}
}
}
}
if(choice2==x||choice2==X)
{
//go to top of main menu loop
continue;
}
else
{
}
if(choice==v||choice==V)
{
displayAccount();
}
else
{
}
char choice3;
cout<<"Enter 'C' to continue or 'X' to exit.";
cin>>choice3;
if(choice3==c||choice3==C)
{
//go to top of main menu loop
continue;
}
else
{
switch(choice3)
{
case x:
case X:
//exit program
break;
default:
cout<<"You did not enter a 'C' or an 'X'.";
}
}
}
return 0;
}