Question
Modify the Lookup program given in the textbook (program 4.4.1) to make a program LookupMultipleNumber that prints out multiple values having the same key. [MO7.1]
Modify the Lookup program given in the textbook (program 4.4.1) to make a program LookupMultipleNumber that prints out multiple values having the same key. [MO7.1] Notes: The user would specify the maximum number of values to be printed out for each key as a command line argument after the file name.
Store all such multiple values in a queue. So each element of the symbol table would have a string as a key and a queue object as its value.
Sample runs would be as follows (refer to input file amino.csv). >java LookupMultipleNumber amino.csv 2 3 0 Tryptophan TGG Cysteine TGT TGC
>java LookupMultipleNumber amino.csv 6 3 0 Cysteine TGT TGC Leucine TTA TTG CTT CTC CTA CTG
more amino.csv TTT, Phe, F, Phenylalanine TTC, Phe, F, Phenylalanine TTA, Leu, L, Leucine TTG, Leu, L, Leucine TCT, Ser, S, Serine TCC, Ser, TCL,Ser, TCG, Ser, TAT, Tyr, Y, Tyr TAC, Tyr, Y, Tyrosine TAA, Stop, Stop, Stop OOH... H. HDD (D 0 0 GCA, Ala, A, Alanine GCG, Ala, A, Alanine GAT, Asp, D, Aspartic Acid GAC, Asp,D, Aspartic Acid GAA, Gly,G,Glutamic Acid GAG, Gly,G,Glutamic Acid GGT, Gly, G, Glycine GGC, Gly, G, Glycine GGA, Gly, G, Glycine GGG, Gly, G, Glycine more DJIA.CSV 20-Oct-87,1738.74,608099968,1841.01 19-Oct-87,2164.16, 604300032, 1738.74 16-Oct-87,2355.09, 338500000, 2246.73 15-Oct-87,2412.70,263200000, 2355.09 30-Oct-29, 230.98,10730000,258.47 29-Oct-29, 252.38,16410000, 230.07 28-Oct-29, 295.18, 9210000, 260.64 25-Oct-29, 299.47,5920000, 301.22 0 0 OOOO 0 0 cfcfcfcf more ip.csv www.ebay.com, 66.135.192.87 www.princeton.edu, 128.112.128.15 www.cs.princeton.edu, 128.112.136.35 www.harvard.edu, 128.103.60.24 www.yale.edu, 130.132.51.8 www.cnn.com, 64.236.16.20 www.google.com, 216.239.41.99 www.nytimes.com, 199.239.136.200 www.apple.com, 17.112.152.32 www.slashdot.org, 66.35.250.151 www.espn.com, 199.181.135.201 www.weather.com, 63.111.66.11 www.yahoo.com, 216.109.118.65 Typical comma-separated-value (CSV) files D i t 1... .. . 11... . . ... .... . ..... .. .... ......151...2.1. ........1..1-11..1... . 11... integers, one specifying the field to serve as the key and the other specifying the field to serve as the value. Program 4.4.1 Dictionary lookup Click here to view code image public class Lookup public static void main(String[] args) // Build dictionary, provide values for keys in StdIn. In in = new In (args[0]); int key Field = Integer.parseInt(args[1]); int valField = Integer.parseInt (args (2]); String[] database = in.readAllLines(); StdRandom.shuffle (database); STStep 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