Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hint: In the constructor, if the upper bound is smaller than the lower bound, then simply swap the bounds. Also, your data range should not

Hint: In the constructor, if the upper bound is smaller than the lower bound, then simply swap the bounds. Also, your data range should not include negative numbers or fractions. In the toString()method, the character adds newlines. JAVAimage text in transcribed

Page of 7 ZOOM 3 Histogram Part 1 Recall that a histogram is a visual representation of a distribution of discrete data. For example, the data set (3, 2, 1, 2, 3,0,1,5, 3} over the range 0.5) will have the following histogram: 0: 2:44 Figure 1: Example Histogram Your histogram will be stored as an array. Remember, an array element is essentially two com- ponents: its index, the order in which it appears in the array (starting at 0), and i value, the mutable piece of data that corresponds to each index. For the histogram, notice that the value of each array element is the frequency of its index in the data set. When programming it is important to break your problems down into small pieces. For this section, you will create a Histogram class with a way to store the information in a histogram as follows: Add a constructor public Histogram(int lower bound, int upperbound) which will ini- tialize your histogram by setting the range. This constructor is also where you should create the class member array that keeps track of the frequency of each mmber between lowerbound and upperbound inclusive. Add a method public boolean add(int i) - If i is between lowerbound and upperbound inclusive, then add i to the histogram and return true. Otherwise, return false. Hint: If you trying to increase the frequency of i in the histogram array, then you will need to offset the index of the array by the lower bound. For example, if louerbound = 5, upperbound = 10, and i = 6, then to increase the frequency of i = 6 in our histogram array, we would need to access the array at index [i lower bound) - [1]. Add a method public String toString() - This will return a String formatted as in Figure 1. That means you are not printing anything in this method. Make sure your data points are in order from lower bound to upperbound. Create the main method. Inside, implement some tests on an instance of Hiatogram to confirm that everything is working correctly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago

Question

What could motivate staff to participate?

Answered: 1 week ago