Question
Required Files coins.txt Those data are obtained from worldcoinindex.com API. It includes one long line text inside it, which has values of all cryptocurrencies. Please
Required Files
- coins.txt
Those data are obtained from worldcoinindex.com API. It includes one long line text inside it, which has values of all cryptocurrencies. Please do not modify the coins.txt file.
Task #1 Store coin data in an ArrayList (10 pts)
- Create a Coin class that represents each coin information with attributes inside { and } in the coins.txt file. Make sure that all fields are private and use getter and setter methods to access and modify the fields of Coin.
- Create another class named StoreCoinArrayList class. You do not create the main method in the StoreCoinArrayList.
- Edit StoreCoinArrayList and create ArrayList field, which can hold Coin type data.
private ArrayList list = new ArrayList();
- You need to use your homework 1 code in a method inside StoreCoinArrayList to read coin data from coins.txt file, and then create a Coin Object for each coin and add created coins to ArrayList when the constructor is called for StoreCoinArrayList.
- Then, write four methods called findMin, findMax, searchName, and size in StoreCoinArrayList.
- findMin method takes priceType as String and returns the Coin with the minimum price for the given type in the list.
- findMax method takes priceType as String and returns the Coin with the maximum price for the given type in the list.
- searchName method takes a name as String and returns true or false whether the name of the Coin exists in the list.
- size method returns int that shows how many Coin in the list.
- Use the Junit test to test your four methods of StoreCoinArrayList are correct for different cases.
Task #2 Store coin data in an Array (10 pts)
- Create another class named StoreCoinArray class. You do not create the main method in the StoreCoinArray.
- Edit StoreCoinArray and create Array field, which can hold Coin type data.
private Coin [] array = new Coin[50];
- You need to use your homework 1 code in a method inside StoreCoinArray to read coin data from coins.txt file, and then create a Coin Object for each coin and add created coins to the array when the constructor is called for StoreCoinArray. As you can see, the initial size of the array is 50. You need to increase the size of array by adding 100 more as much as you need.
- Then, write four methods called findMin, findMax, searchName, and size in StoreCoinArray.
- findMin method takes priceType as String and returns the Coin with the minimum price for the given type in the array.
- findMax method takes priceType as String and returns the Coin with the maximum price for the given type in the array.
- searchName method takes a name as String and returns true or false whether the name of the Coin exists in the array.
- size method returns int that shows how many Coin in the array.
- Use the Junit test to test your four methods of StoreCoinArray are correct for different cases.
Task #3 Big-O based Runtime Analysis (10 pts)
- Give the Big-O runtime of the following code parts as much as tight.
for (int i = 0; i < N; i++) { sequence of statements } for (int j = 0; j < M; j++) { sequence of statements } for (int i = 0; i < N; i++) { for (j = 0; j < N; j+=2) { sequence of statements } } for (int k = 0; k < N; k = k+4) { sequence of statements } for (int i = 0; i < N; i++) { for (int j = N; j > i; j--) { sequence of statements } } for (int i = 0; i < N; i++) { for (int j = N; j > i; j-2) { sequence of statements } } | for (int i = 0; i < N; i++) { for (int j = i+1; j < N; j++) { sequence of statements } }
for (int i = 0; i < N; i++) { for (int j = N; j > i; j= j--) { sequence of statements } }
for (int i = 0; i < N; i++) { for (int j = 1; j < N; j= j*3) { sequence of statements } }
for (int i = 0; i < N; i++) { for (int j = 1; log(j) < N; j= j*2) { sequence of statements } } for (int i = 0; i < N; i++) { for (int j = 1; log(j) < N; j= j+1) { sequence of statements }
|
coins.txt file : https://drive.google.com/file/d/150hp232orM7aOkOa4qS12je27UBML342/view?usp=sharing
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started