Design, code, and test a program that reads a file containing a sequence of doub
ID: 3628804 • Letter: D
Question
Design, code, and test a program that reads a file containing a sequence of doubles and reports the longest run length in the sequence.
Background
A run is a non-decreasing segment of adjacent numbers in a sequence.
The sequence 1.3 7.4 7.4 9.2 3.1 -1.6 8.4 has 3 runs with lengths 4, 1, and 2. The first run is 1.3 7.4 7.4 9.2. The second run is 3.1. The last run is -1.6 8.4. The first run is the longest.
A Simple Accumulator, LastRunLength, can track the length of the last run in a sequence.
A Simple Accumulator, LongestRunLength, can track the longest run length in a sequence. This Simple Accumulator can be written using a LastRunLength object and a Largest object as data members.
Tasks:
1. Think about program cases for this problem. Partition the cases into several categories and create a test file for an instance from each category. Assume the file to be read is a valid sequence of doubles. Consider the number of runs, the length of the runs, and the position of the longest run in the sequence.
2. Write source code for the LastRunLength and LongestRunLength tracker classes.
3. Write a driver program that reads a file of numbers and reports, to the screen, the longest run length in the sequence(OPTIONAL)
nOTE: i JUST WANT CODE FOR LAST RUN LENGTH AND LONGESTRUNLENGTH..
TAKE AS MUCH TIME AS U WANT..IF U CAN DO IT TILL WEDNESDAY EVENING ..I WILL still reward you 350 karma points...
i would appreciate your help a lot! this assignment is very important for me
Explanation / Answer
this will return the longest run of increasing numbers in a sub set. This should give you an idea of what to do for the other function. Sorry about the way cramster formats code.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.