This assignment will exercise reference parameters, value parameters, and (most important) program decomposition.
This program will act as a bank. The general behavior will be:
• User walks into the bank
• User opens an account. This consists of:
o Asking the user for a name.
o Asking the user for an account balance.
o Asking the user for an interest rate. (OK, this is a very nice bank!)
• The user now gets to perform transactions until leaving the bank. These transactions are:
o Create an account. The user should supply his id , the initial amount of money deposited and choose to create either a saving or current account.
o Print a statement. This statement should say something like, "Hello (your name), your account balance is (amount) and your current interest rate is (rate)". You can make this more fancy if you want.
o Make a deposit. This should ask you for the amount, add it, and then print your balance (or, call the function which prints a statement)
o Make a withdrawal. Same as deposit. You could add some error checking to this routine as well.
o Financial planning. Ask the user for the current month and year. Ask for the retirement month and year. Using the number of years between and the current interest rate, project the amount the user will have upon retirement.
Hints:
• Declare a function for each of the operations. Declare more functions to support them if needed.
• No globals that aren't constants. Pass the account info around as a function argument.
• Try to use references variable whenever possible
• Feel free to embellish operations, especially the financial planning one. You can also add more operations if you are motivated.

#include <iostream>
#include <string>

using namespace std;
void create (string& name,long double& ic,long double& deposit,long double& rate);
void print (string name,long double ic,long double amount,long double rate);
void deposit (long double& balance,long double amount);
void withdrawal (long double& balance);

int main()
{
    int resp,ic,acc,transaction;
    long double deposit,rate,amount,balance;
    string name;
    int choose_acc (double& rate);
    
    system("cls");
    system("color 05");
    cout<< "     @           @  @ @ @ @  @         @ @ @    @ @ @   @       @  @ @ @ @     " <<endl; 
    cout<< "      @         @   @        @        @     @  @     @  @@     @@  @           " <<endl; 
    cout<< "       @   @   @    @ @ @    @        @        @     @  @ @   @ @  @ @ @       " <<endl;    
    cout<< "        @ @ @ @     @        @        @     @  @     @  @  @ @  @  @           " <<endl;    
    cout<< "         @   @      @ @ @ @  @ @ @ @   @ @ @    @ @ @   @   @   @  @ @ @ @     " <<endl;  
    
    cout<< "         @@@@@   @@@        @    @     @  @@@@     @    @   @  @   @           " <<endl;
    cout<< "           @    @   @      @ @   @@   @@  @   @   @ @   @@  @  @  @            " <<endl;
    cout<< "           @    @   @     @ @ @  @ @ @ @  @ -@   @ @ @  @ @ @  @ @             " <<endl; 
    cout<< "           @     @@@     @     @ @  @  @  @ @ @ @     @ @  @@  @   @           " <<endl;
    cout<<"\n\n\n";
    
    
    cout<<"Create an account?"<<endl
        <<"If YES press 1, If no press 2."<<endl;
    cin>>resp;
    
    if (resp==2)
        {  
        cout<<"Thank You for visiting!"<<endl;
        }
    else  
        {
         create (name,ic,deposit,rate);
         balance = amount;
         
    cout<<"                          Choose the Service:-          "<<endl;
    cout<<"                          ____________________________  "<<endl;
    cout<<"                          ' 1. Deposit               '  "<<endl;
    cout<<"                          ' 2. Withdrawal            '  "<<endl;
    cout<<"                          ' 3. Financial Planning    '  "<<endl;
    cout<<"                          ' 4. Checking Balance      '  "<<endl;
    cout<<"                          ' 5. Leaving               '  "<<endl;
    cout<<"                          ____________________________  "<<endl;
    cin>>transaction;
    cout<<endl;
    
    }
    
    do 
    {
        switch (transaction)
        case 1:
             void deposit();
             break;
        case 2:
             void withdrawal();
             break;
        case 3:
             financial planning();
             break;
        case 4:
             checking balance();
             break;
        case 5:
             leaving();
             break;
        default:
             cout<<"ERROR!"<<endl;
             break;
   } 
   while (resp 2 == true)
        
        system ("PAUSE");
        return 0;
        }

void create (string& name,int& ic,long double& deposit,long double& rate)
{
     cout<<"Enter your IC no.:";
     cin>>ic;
     cout<<"Enter your Full Name:";
     cin>>name;
     cout<<"Deposit amount:";
     cin>>deposit;
     }
     
int choose_acc (double& rate);
{
         do
         {
                int acc;
                
                cout<<"Which acc to open?"<<endl
                    <<1. Saving Account<<endl
                    <<2. Current Account<<endl;
                    
                cin>>acc;
                if (acc==1)       rate = 0.05;
                else if (acc==2)  rate = 0.10;
                else              cout<<"Invalid no.!"<<endl;
                }
         while (acc==1)||(acc!=2)
         
void print (string name,long double IC,long double amount,long double rate);
{
     cout<<"Thank You for choosing AmBank!"<<endl
         <<"-------------------------------"<<endl
         <<"Name: "<<name<<endl
         <<"IC no: "<<ic<<endl
         <<"Amount in acc: "<<amount<<endl
         <<"Current rate: "<<rate<<endl
         <<"-------------------------------"<<endl;
         
         system("PAUSE");
         system ("cls");
}

void deposit (long double& balance,long double amount);
{
     
     cout<<"Amount to deposit: RM ";
     cin>>amount;
     balance = balance + amount;
}

void withdrawal (long double& balance);
{
     cout<<"Amount to withdraw: RM ";
     cin>>amount;
     
     if (amount<balance)   balance = balance - amount;
     else                  cout<<"not enough money!"<<endl;
}

void financial_planning (

help me with my coding...i have no idea what is going wrong here...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.