Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program 1 , “ Histogram ,” takes an integer “n,” and two integers “left and righ

ID: 3742400 • Letter: P

Question

Program 1, “Histogram,” takes an integer “n,” and two integers “left and right,” and uses “StdDraw” to plot a histogram of the count of the numbers in the standard input stream that fall in each of the n intervals defined by dividing (left, right) into n equal-sized intervals.

Note: The program is to read the values from an input file whose first line would contain “n,” “left,” and “right” values. The remaining lines would contain the sequence of integer values.

A sample run would be as follows.

>more data.txt

4 40 80

52 41 72 61

71 60 50 52 61

77 41 61 70 79 41

67 60 50 61 76

>java Histogram < data.txt

It should plot a histogram where the x-axis points are 40, 50, 60, 70, 80 and the intervals are 40-50, 50-60, 60-70, 70-80. The height of the rectangles for the intervals should be 3, 4, 7, 6 respectively.

Explanation / Answer


Hi. please find the answer above.. In case of any doubts, please ask in comments. If the answer helps you, please upvote. Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote