Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

  1. 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.
  2. Create another class named StoreCoinArrayList class. You do not create the main method in the StoreCoinArrayList.
  3. Edit StoreCoinArrayList and create ArrayList field, which can hold Coin type data.

private ArrayList list = new ArrayList();

  1. 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.
  2. Then, write four methods called findMin, findMax, searchName, and size in StoreCoinArrayList.
    1. findMin method takes priceType as String and returns the Coin with the minimum price for the given type in the list.
    2. findMax method takes priceType as String and returns the Coin with the maximum price for the given type in the list.
    3. searchName method takes a name as String and returns true or false whether the name of the Coin exists in the list.
    4. size method returns int that shows how many Coin in the list.

  1. 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)

  1. Create another class named StoreCoinArray class. You do not create the main method in the StoreCoinArray.
  2. Edit StoreCoinArray and create Array field, which can hold Coin type data.

private Coin [] array = new Coin[50];

  1. 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.
  2. Then, write four methods called findMin, findMax, searchName, and size in StoreCoinArray.
    1. findMin method takes priceType as String and returns the Coin with the minimum price for the given type in the array.
    2. findMax method takes priceType as String and returns the Coin with the maximum price for the given type in the array.
    3. searchName method takes a name as String and returns true or false whether the name of the Coin exists in the array.
    4. size method returns int that shows how many Coin in the array.

  1. 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)

  1. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago