Java Reference
In-Depth Information
16. Programming Project 3.15 asked you to explore Benford's Law. An easier way to
write the program is to use an array to store the digit counts. That is, count[0]
might store the number of times 0 is the first digit (if that is possible in your data
set), count[1] might store the number of times 1 is the first digit, and so forth.
Redo Programming Project 3.15 using arrays.
Write a program that tests Benford's Law. Collect a list of at least 100 numbers
from some real-life data source and enter them into a text file. Your program
should use an array to store the digit counts. That is, count[0] might store the
number of times 0 is the first digit (if that is possible in your data set), count[1]
might store the number of times 1 is the first digit, and so forth. For each digit,
output the percentage it appears as the first digit.
17. Programming Project 4.14 asked you to read in a CSV file of product ratings. The
file was limited to exactly five products. Redo Programming Project 4.14, except
calculate the name of each product and how many products are in the file based
on the header line. Then read the CSV file and translate the data into a 2D array
that stores all of the ratings. Finally, output the average rating for each product.
18. Programming Project 4.13 asked you to create a BoxOfProduce class representing
a box of produce to deliver from a CSA farm. The box contained exactly three
items. Modify the class so it uses an array of type String to represent the items
in the box. You can still start with three random items to place in the box, but
your menu should be modified to allow the user to add additional items and still
substitute one item for another. You will likely need to modify the constructor of
the BoxOfProduce class and also add new methods.
19. Some word games require the player to find words that can be formed using the let-
ters of another word. For example, given the word SWIMMING , other words that
can be formed using the letters include SWIM , WIN , WING , SING , MIMING ,
etc. Write a program that lets the user enter a word and then output all the words
contained in the file words.txt that can be formed from the letters of the entered
word. One algorithm to do this is to compare the letter histograms for each word.
Create an array that counts up the number of each letter in the entered word (e.g.,
one S, one W, two I, two M, etc.) and then creates a similar array for the current
word read from the file. The two arrays can be compared to see if the word from
the file could be created out of the letters from the entered word.
Search WWH ::




Custom Search