Question: Using Java, you are going to write a program to create a histogram. A histogram draws bars that represent the values of different categories. For
Using Java, you are going to write a program to create a histogram. A histogram draws bars that represent the values of different categories. For example:
Favorite color of CSE students
Blue @@@@@@@
Green @@@@@@@@@@@@
Red @@@@@
Silver @
Yellow @@@
Create a Project called Lab6 and Class named Histogram
Write methods to do the following:
public static void drawBar(int n) Prints a row of @ (length n)
public static void drawItem(String s, int n) Prints the string s, followed by a bar of length n
public static void drawHistogram(String title, String[] items, int[] values) Prints the entire histogram with a title. Note that the items and values are arrays.
Then use the main() method to initialize the arrays and print the histogram at the beginning of this lab. Recall that you can declare and initialize an array in a single statement.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
