Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4071680
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:47:16+00:00 2026-05-20T16:47:16+00:00

I have this text file with customer, account and transaction information in. Each item

  • 0

I have this text file with customer, account and transaction information in. Each item appears in the order just mentioned line by line.

Dr
James
M
Magee
12/05/1978
12
Dakedon Avenue
Mutley
Plymouth
Devon
PL87TS
babiesrus123
2
54-25-36
2455871265
jennies uni account !!!
02/12/1999
-25.36
2000
8
02/02/2010
OTR
Scottish Highlands Vacations Inc.
-650
-675.36
02/02/2010
C/R
Mobiles Inc  - month 4  cash back 
20
-655.36
05/02/2010
OTR
C.Oldgam Travel Insurance service
-44.55
-699.91
08/02/2010
POS
Wrapping Up.Net
-800
-1499.91
12/02/2010
OTR
Carphone Warehome
-145
-1644.91
17/02/2010
D/D
Leather World - loan repayment
-75
-1719.91
22/02/2010
D/D
park deans - loan repayment
-88.56
-1808.47
02/03/2010
ATM
Stirling University
-120
-1928.47
58-69-71
12455871265
johns uni account !!!
02/12/1999
-25.36
1500
6
02/02/2010
D/D
SUBar Monthly Bill- Plymouth
-259.99
-285.35
02/02/2010
C/R
Monthly allowance
450
164.65
02/02/2010
D/D
SUBar Monthly Bill- Plymouth
-325.36
-160.71
02/02/2010
C/R
Monthly allowance
450
289.29
02/02/2010
D/D
SUBar Monthly Bill- Plymouth
-78.36
210.93
02/02/2010
C/R
Monthly allowance
450
660.93

In the above snippet from the file is:
1 Customer
2 Accounts
Each Account has several Transactions.

How would i read this information into a Single? ArrayList Data Structure whilst using get and set methods in classes(Customer, Account, Transaction). Whats confusing me is how would i read in this data and keep track of how many accounts a customer has and how many transactions an account has.

From what i think needs doing is a big nested loop to read the information from the text file and keep track of how much information each item has.

Loop through Customer 1
    Loop through Customer Account 1
       Loop through Customer Account 1 Transactions
    Loop through Customer Account 2
       Loop through Customer Account 2 Transactions
Loop through Customer 2
...

About the text file:

•   Customer ID number --- this is the first customer 1
•   Customer title
•   Customer first name
•   Customer initials  //not required - defaults to null
•   Customer surname
•   Customer date of birth
•   Customer house name or number
•   Customer street name
•   Customer address area  //not required - defaults to null
•   Customer city or town name
•   Customer county
•   Customer postcode
•   Customer password *minimum size is 8 characters in length
•   The number of accounts belonging to this customer ---  equals 2 in this example

    o   Account sort code --- this is the first account of customer 1
    o   Account Number
    o   Account Nick Name //not required – defaults to null
    o   Date the account was created
    o   Current account balance
    o   Account  overdraft limit
    o   Number of transactions available for this account---  equals 2 in this example 

           Transaction Date --- this is the first transaction of account 1
           Transaction Type
           Transaction Description
           Transaction Amount
           Transaction Balance after transaction has been applied to account

           Transaction Date --- this is the second transaction of account 1
           Transaction Type
           Transaction Description
           Transaction Amount
           Transaction Balance after transaction has been applied to account

    o   Account sort code --- this is the second account of customer 1
    o   Account Number
    o   Account Nick Name //not required – defaults to null
    o   Date the account was created
    o   Current account balance
    o   Account  overdraft limit
    o   Number of transactions available for this account---  equals 2 in this example

           Transaction Date --- this is the first transaction of account 2
           Transaction Type
           Transaction Description
           Transaction Amount
           Transaction Balance after transaction has been applied to account

           Transaction Date --- this is the second transaction of account 2
           Transaction Type
           Transaction Description
           Transaction Amount
           Transaction Balance after transaction has been applied to account


•   Customer ID number --- this is the second customer 
•   Customer title
•   Customer first name
•   Customer initials  //not required - defaults to null
•   Customer surname
•   ...
•   ...
•   ...

Any help is VERY MUCH apreciated!

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:47:17+00:00Added an answer on May 20, 2026 at 4:47 pm

    Ok then perhaps this will help:

    Update the Customer class with a Generic Account List property.

     private int numberAccounts;
    
            public List<Account> Accounts {
                get;
                protected set;
            }
    
            public Customer(string theCustomerNumber, string theCustomerTitle, string theFirstName, string theInitials, string theSurname, string theDateOfBirth, string theHouseNameNumber, string theStreetName, string theArea, string theCityTown, string theCounty, string thePostcode, string thePassword, string theNumberAccounts)
            {
                customerNumber = theCustomerNumber;
                customerTitle = theCustomerTitle;
                firstName = theFirstName;
                initials = theInitials;
                surname = theSurname;
                dateOfBirth = theDateOfBirth;
                houseNameNumber = theHouseNameNumber;
                streetName = theStreetName;
                area = theArea;
                cityTown = theCityTown;
                county = theCounty;
                postcode = thePostcode;
                password = thePassword;
                setNumberAccounts(theNumberAccounts);
                Accounts = new List<Account>();
            }
    

    Update the Account with a Generic Transaction List Property

    public List<Transaction> Transactions {
        get;
        protected set;
    }
    
    public Account(string theAccSort, string theAccNumber, string theAccNick, 
                   string theAccDate, string theAccCurBal, string theAccOverDraft, 
                   string theAccNumTrans)
    {
        accSort = theAccSort;
        setAccNumber(theAccNumber);
        accNick = theAccNick;
        accDate = theAccDate;
        setAccCurBal(theAccCurBal);
        setAccOverDraft(theAccOverDraft);
        setAccNumTrans(theAccNumTrans);
        Transactions = new List<Transaction>();
    }
    

    Comment out your “readData()” method and replace with this:

     private void readData() {
                ///read all the data into memory (if you can)
                string[] _data = File.ReadAllLines(inputDataFile);
                Queue<String> _lines = new Queue<string>();
                foreach (string _line in _data) {
                    _lines.Enqueue(_line.Trim()); //put it into a queue for convience
                }
    
                ///iterate through the data and extract the details based on 
                ///known record delimiters.
                while (_lines.Count > 0) {
                    Customer _customer = new Customer(
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue(),
                        _lines.Dequeue());
                    int _numberOfAccounts = _customer.getNumberAccounts();
                    for (int i = 1; i <= _numberOfAccounts; i++) {
                        Account _account = new Account(
                            _lines.Dequeue(),
                            _lines.Dequeue(),
                            _lines.Dequeue(),
                            _lines.Dequeue(),
                            _lines.Dequeue(),
                            _lines.Dequeue(),
                            _lines.Dequeue());
                        int _numberOfTransactions = _account.getAccNumTrans();
                        for (int j = 1; j <= _numberOfTransactions; j++) {
                            Transaction _transaction = new Transaction(
                                _lines.Dequeue(),
                                _lines.Dequeue(),
                                _lines.Dequeue(),
                                _lines.Dequeue(),
                                _lines.Dequeue());
                            _account.Transactions.Add(_transaction);
                        }
                        _customer.Accounts.Add(_account);
                    }
    
                    ///update the legacy part of the system.
                    bankDetails.Add(_customer);
                    foreach (Account _account in _customer.Accounts) {
                        accDetails.Add(_account);
                        foreach (Transaction _transaction in _account.Transactions) {
                            tranDetails.Add(_transaction);
                        }
                    }
                }
            }
    

    EDIT: Comment out your “showListsOfCust” method and put this in it’s place

    private void showListsOfCust() {
                listBox1.Items.Clear();
    
                foreach (Customer c in bankDetails) {
                    listBox1.Items.Add(c.getCustomerNumber() + " " + c.getCustomerTitle() + " " + c.getFirstName()
                                       + " " + c.getInitials() + " " + c.getSurname() + " " + c.getDateOfBirth()
                                       + " " + c.getHouseNameNumber() + " " + c.getStreetName() + " " + c.getArea()
                                       + " " + c.getCityTown() + " " + c.getCounty() + " " + c.getPostcode()
                                       + " " + c.getPassword() + " " + c.getNumberAccounts());
                    foreach (Account a in c.Accounts) {
                        listBox1.Items.Add(a.getAccSort() + " " + a.getAccNumber() + " " + a.getAccNick() + " " + a.getAccDate()
                                           + " " + a.getAccCurBal() + " " + a.getAccOverDraft() + " " + a.getAccNumTrans());
    
                        foreach (Transaction t in a.Transactions) {
                            listBox1.Items.Add(t.getDate() + " " + t.getType() + " " + t.getDescription() + " " + t.getAmount()
                                               + " " + t.getBalAfter());
                        }
                    }
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in PHP writing views to a text-file and just increasing
I have a text file like this: A B C And each element has
I have text file with some text information and i need to split this
I have a text file with content like this customer-1 Product-2 customer-1 Product-3 customer-1
I have got this text file with latitude and longitude values of different points
I have a text file exported from a Foxpro (Dos-based) program, but this text
I have a text file that looks like this. A 102 B 456 C
I have this xml file which has text init. i.e Hi my name is
I have a text file looks like this : 100 50 20 90 4.07498
I have a text file that looks like this: value1 value2 value3 There are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.