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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started