The file transactions.txt contains rows of transactions. Each transaction (row) consists of a start month, end month and name. Each of these three values is a String. In the following tasks you are asked to read and store the transactions from the file and determine if there are any duplicate transactions. A transaction is a duplicate if all three values are the same as the three values of any other transaction. a. add code to your main method that reads the content of transactions.txt and stores it in a two-dimensional String array. The name of the String array is your choice. Note that you may not assume that the number of rows in transactions.txt will always be the same. However, you may assume that there will always be three String values on a single row. The first dimension of your two-dimensional array must be resized dynamically each time a new record is read (Hint: we did this in class with a single dimensional array and this is very, very similar). Your code will be evaluated with rows in transaction.txt that you have not seen. b. Create a method named checkForDuplicates that returns a boolean and accepts a twodimensional ‘String1 array as an argument. c. In checkForDuplicates check to see if any two rows of the two-dimensinal array provided as an argument to the method are the same. You must use at least one enhanced for-loop in this method. Return true if ANY two equivalent rows are found and false otherwise. d. In the main method call checkForDuplicates with the two-dimensional array containing the transactions data read from transactions.txt. Print a message to the console indicating whether any duplicate transactions exist in transactions.txt.
The file transactions.txt contains rows of transactions. Each transaction (row) consists of a start month,
end month and name. Each of these three values is a String.
In the following tasks you are asked to read and store the transactions from the file and determine if there
are any duplicate transactions. A transaction is a duplicate if all three values are the same as the three
values of any other transaction.
a. add code to your main method that reads the content of transactions.txt and stores it
in a two-dimensional String array. The name of the String array is your choice. Note that you may
not assume that the number of rows in transactions.txt will always be the same. However, you
may assume that there will always be three String values on a single row. The first dimension of your
two-dimensional array must be resized dynamically each time a new record is read (Hint: we did this
in class with a single dimensional array and this is very, very similar). Your code will be evaluated
with rows in transaction.txt that you have not seen.
b. Create a method named checkForDuplicates that returns a boolean and accepts a twodimensional ‘String1 array as an argument.
c. In checkForDuplicates check to see if any two rows of the two-dimensinal array provided as an
argument to the method are the same. You must use at least one enhanced for-loop in this method.
Return true if ANY two equivalent rows are found and false otherwise.
d. In the main method call checkForDuplicates with the two-dimensional array containing
the transactions data read from transactions.txt. Print a message to the console indicating whether
any duplicate transactions exist in transactions.txt.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images