I need some help please with Java and arrays.
I have two arrays: customerID and transactionValue (they are pairs so each transaction has a customer ID and a customer may have made several transactions).
The number of elements in each array has an int variable called ‘size’.
I need to work out, and display( using loops and ‘if’ statements): for each customer I need to display the number of transactions that are on the list.
So I thought I could use variable (int for customer ID and double for transaction values) to “go through the array and count the number of times that for example customer 0 is represented, when that is done do the loop again and see how many times customer 1 is represented and so on”.
This is my initial thoughts but I may be totally wrong, and clearly I need more code:
System.out.println ("The count is= "+count);
The final output must look something like this:
Customer ID Transaction Value
Customer: 2, Transactions:1
Customer: 1, Transactions: 1
Customer: 3, Transactions 3
Customer: 0, Transactons: 1
Customer: 4, Transactions: 1
I have been struggling for hours so any pointers would be most welcome- thanks