954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Helpppppppp!!!!!!!!

how can i display all the account numbers that have been entered.
it only shows the last account number entered, not any before it.

heres the code-

#include <iostream>

using namespace std;

int main()
{
    double deposit;
    double previous;
    double newtotal;
    double withdraw;



    int total;
    int number;
    int res;

    total = 0;



    cout << " WELCOME TO MSIBANK " << endl;
    cout  << endl;

    cout  << "Enter 1 to process an account or 0 to stop" << endl;
    cin >> res;

    while(res == 1)
    {
        cout  << "Enter account number please" << endl;
    cin >> number;
    cout  << " Enter present amount in account: " << endl;
    cin >> previous;
    cout << " Enter deposit amount: " << endl;
    cin >> deposit;
    cout << "Enter withdraw amount: " << endl;
    cin >> withdraw;

    newtotal = previous - withdraw + deposit;


    cout << " Previous total: " << previous << endl;
    cout  << " Deposit amount: " << deposit << endl;
    cout  << " Withdraw amount: " <<  withdraw << endl;
    cout << endl << endl;
    cout << "--------------------------------------------------" << endl;
    cout  << " Present total: " << newtotal << endl;




    ++total;


     cout  << "Enter 1 to process an account or 0 to stop" << endl;
    cin >> res;

    }
      cout << "---------------------------------------" << endl;
      cout << " Acount numbers: " << number << endl;
      cout << " Total accounts processed: " << total;

    }
Mayank23
Light Poster
31 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

You will have to maintain an array of account numbers. In certain circumstances a programming teacher may accept a statically allocated array--when learning the basics of programming.

If you don't know how to use arrays, I suggest you learn how. Truthfully there are (probably) infinite ways to accomplish the task, however.

pseudorandom21
Practically a Posting Shark
890 posts since Jan 2011
Reputation Points: 216
Solved Threads: 111
 

thanks for your help i appreciate it.

Mayank23
Light Poster
31 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: