Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A java code to search for a given keyword, e.g., robot, fitness, wearable and the result should present fund_raised_percent and close_date. (Note: I have wrote

A java code to search for a given keyword, e.g., "robot", "fitness", "wearable" and the result

should present "fund_raised_percent" and "close_date". (Note: I have wrote the code for this but struggling after this)

? The search should include a memory. The memory means that it keeps the track of what has been searched. In simple words, you need tostoreinputs which we give to the search.

? This means the search criteria and timestamp, should be stored in acollection.

? There should be a method to call and print the number of search terms, their timestamps,

and frequency.

Code for keyword searched is following:

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

class TestSearch {

class Pair {

String clickthrough_url;

String close_date;

String funds_raised_percent;

public Pair(String url, String closeDate, String fundsRP) {

this.clickthrough_url = url;

this.close_date = closeDate;

this.funds_raised_percent = fundsRP;

}

}

ArrayList data = new ArrayList<>(); // Stores the data of file

// Reads the data from file to data List

void readData(String fileName) throws FileNotFoundException, IOException {

try (BufferedReader br = new BufferedReader(new FileReader("file3.csv"))) {

// Reading the next line

String line = br.readLine();

// If next line is not null

while (line != null) {

// Getting the columns and adding it to data List

String[] columns = line.split(",");

data.add(new Pair(columns[2], columns[3], columns[6]));

line = br.readLine();

}

}

}

// Searching for the clickthrough_url in data List

void searchInUrl(String word) {

System.out.println(" Searching word: " + word);

for (Pair line : data) {

// If word is present in the url then printing it

if (line.clickthrough_url.toLowerCase().contains(word.toLowerCase())) {

System.out.println(line.close_date + " " + line.funds_raised_percent);

}

}

}

public static void main(String[] args) throws FileNotFoundException, IOException {

TestSearch ts = new TestSearch();

ts.readData("file3.csv");

// Searching the text in the file data

ts.searchInUrl("robot");

ts.searchInUrl("fitness");

ts.searchInUrl("wearable");

}

}

File3.csv screen shot:

image

AutoSave Off file3.csv Search (Alt+Q) Page Layout Formulas Data Review View Help 2 Fashion & Wearables /explore/fashion-wearables/projects/compact-toothbrush 4 Fashion & Wearables /explore/fashion-wearables /projects/red-furore-an-epic-fanny-relaunch 5 Music /projects/irene-diaz-lovers-and-friends Fashion & Wearables /explore/fashion-wearables /projects/kimono-pocket-purse-kinchaku Fashion & Wearables /explore/fashion-wearables/projects/youprint-3d-cheapest-3d-printing-company 9 Music 10 Fashion & Wearables /explore/fashion-wearables /projects/watcher-the-first-anti-loss-smart-watch 11 Music 12 Fashion & Wearables /explore/fashion-wearables /projects/nomi-network-charity 14 Fashion & Wearables /explore/fashion-wearables/projects/reptile-clothing 16 Fashion & Wearables /explore/fashion-wearables /projects/okstal-coffee-and-wine-resistant-fine-shirts 17 Music /projects/aide-financiere-pour-1er-album-trio-nazani 18 Fashion & Wearables /explore/fashion-wearables /projects/lureaux-shoes-unique-comfortable-designer-shoes 19 Music File Home Insert Draw J24 fx B 1 category category_url 3 Music /explore/music /explore/music 6 7 Music 8 /explore/music /explore/music /explore/music 13 Music /explore/music 15 Music /explore/music /explore/music /explore/music /explore/music /explore/music /explore/music /explore/music /explore/music /explore/music /explore/music 35 Music /explore/music 37 Music /explore/music /explore/music /explore/music /projects/scott-logan-s-brand-new-full-length-album 20 Fashion & Wearables /explore/fashion-wearables /projects/cirque-it-a-wearable-tech-fashion-circus 21 Music E F clickthrough_url close_date funds_raised_amount funds_raised_percent 2015-03-08T23:59:59-07:00 /projects/new-cd-of-music-from-studio-ghibli-movies 2018-01-29T23:59:59-08:00 20 1345 0.000666667 0.448333333 2015-03-25T23:59:59-07:00 100 2018-11-24T23:59:59-08:00 9408 2015-04-14T23:59:59-07:00 851 0.2 0.37632 0.050058824 /projects/reckoning--5 /projects/fr-n-ns /projects/pre-purchase-spencer-mackenzie-s-new-album /projects/poppa-foster-and-the-grits-go-vinyl 2020-01-15T23:59:59-08:00 2015-04-24T23:59:59-07:00 2021-01-14T23:59:59-08:00 2015-05-01T23:59:59-07:00 2021-06-06T23:59:59-07:00 2015-05-07T23:59:59-07:00 2021-06-20T23:59:59-07:00 5480 0.548 2 0.0001 13693 1.009166667 162 12236 200 0.00324 0.874 0.4 7637 0.803894737 /projects/heatwaves-sam-foster-s-3rd-album 2015-10-13T23:59:59-07:00 2021-10-26T23:59:59-07:00 2015-11-01T23:59:59-08:00 2021-11-14T23:59:59-08:00 2016-07-13T23:59:59-07:00 10 0.002 2485 1.2425 70 0.007 883 0.126142857 134 0.044666667 2021-12-04T23:59:59-08:00 1630 0.271666667 2016-07-30T23:59:59-07:00 845 0.153636364 2021-12-15T23:59:59-08:00 5330 1.046 2016-08-31T23:59:59-07:00 1220 0.0122 /projects/jen-kearney-s-new-album 2021-12-18T23:59:59-08:00 4832 0.322133333 2016-10-10T23:59:59-07:00 6302 0.210066667 2022-01-08T23:59:59-08:00 3924 0.07848 2016-10-14T23:59:59-07:00 165 /projects/new-susanna-lynn-album-and-tour 2022-01-15T23:59:59-08:00 2016-10-31T23:59:59-07:00 1330 0.0825 0.369444444 4988 10070 5945 0.2494 0.287714286 0.330277778 820 1381 0.082 0.002762 /projects/first-ep-by-naomi-piel /projects/i-want-to-have-a-violin 42497 0.345504065 /projects/i-want-to-own-a-guitar /projects/new-ventenner-album 293 1690 10 55.546 0.488333333 0.016095238 0.02 182279 1.604183333 2022-05-19T23:59:59-07:00 1105 /projects/help-launch-aisley-autumn-s-music-career 2022-02-08T23:59:59-08:00 2022-05-25T23:59:59-07:00 874 0.1105 0.029133333 1291 0.023907407 /projects/prajna-grace-lullabies-for-awakening 22 Fashion & Wearables /explore/fashion-wearables /projects/infinity-fitness-bracelet-with-gps--2 23 Music 24 Fashion & Wearables /explore/fashion-wearables /projects/website-now-live-www-mirramirra-com 25 Music /projects/new-christmas-album 26 Fashion & Wearables /explore/fashion-wearables /projects/the-future-of-sunglasses-built-for-the-extreme 27 Music 28 Fashion & Wearables /explore/fashion-wearables /projects/millybutton-nursing-apparel-accessory 29 Music /projects/epic-death-s-2nd-studio-album-the-seer 30 Fashion & Wearables /explore/fashion-wearables /projects/subs-the-world-s-most-eco-friendly-flip-flops 31 Music /projects/jaden-marcus-debut-studio-project 32 Fashion & Wearables /explore/fashion-wearables /projects/gb-defender-powerful-wearable-security-camera 33 Music 34 Energy & Green Tech /explore/energy-green-tech /projects/peakhonor-portable-powerful-eco-friendly-bidet 36 Energy & Green Tech /explore/energy-green-tech /projects/the-bios-urban-farm 2022-01-18T23:59:59-08:00 2017-09-12T23:59:59-07:00 2022-05-01T23:59:59-07:00 2019-11-30T23:59:59-08:00 2022-05-05T23:59:59-07:00 2021-08-18T23:59:59-07:00 2022-05-07T23:59:59-07:00 2021-08-22T23:59:59-07:00 2022-05-10T23:59:59-07:00 38 Energy & Green Tech /explore/energy-green-tech /projects/nitecore-nes1200-portable-outdoor-power-station 2021-10-23T23:59:59-07:00 39 Music 40 Energy & Green Tech /explore/energy-green-tech /projects/2b0-recycling-robots-for-home-office 243088 41 Music 42 43 44 45 46 G

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Sure heres the Java code incorporating the search functionality with memory timestamp tracking and frequency counting Java import javaioBufferedReader import javaioFileNotFoundException import javaioF... 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

Microsoft Visual C# An Introduction to Object-Oriented Programming

Authors: Joyce Farrell

7th edition

978-1337102100

More Books

Students also viewed these Programming questions

Question

How does national culture relate to business structures?

Answered: 1 week ago

Question

How are the residuals used in estimating ?????

Answered: 1 week ago

Question

An example of fixed variable from an event schema is

Answered: 1 week ago