Question: Add a method hasNext to the Sequence interface of Worked Example 9.2 that returns false if the sequence has no more values. Implement a class

Add a method hasNext to the Sequence interface of Worked Example 9.2 that returns false if the sequence has no more values. Implement a class MySequence producing a sequence of real data of your choice, such as populations of cities or countries, temperatures, or stock prices. Obtain the data from the Internet and reformat the values so that they are placed into an array. Return one value at a time in the next method, until you reach the end of the data. Your SequenceDemo class should display the distribution of the last digits of all sequence values.


Data from Example 9.2,

n this Worked Example, we investigate properties of number sequences. A number sequence can be a sequence of measurements, prices, random values, or mathematical values (such as the sequence of prime numbers). There are many interesting properties that can be investigated. For example, you can look for hidden patterns or test whether a sequence is truly random. Problem Statement Investigate how the last digit of each value is distributed. For a given sequence of values, produce a chart such as

0: 105
1: 94
2: 81
3: 112
4: 89
5: 103
6: 103
7: 100
8: 108
9: 105

Norebbol Stockphoto

Norebbol Stockphoto

Step by Step Solution

3.48 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is the updated code for the Sequence interface and the implementation ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Concepts Late Objects Questions!