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

Write a program using the function void bar_chart(double values[], int size) tha

ID: 3637087 • Letter: W

Question

Write a program using the function
void bar_chart(double values[], int size)
that displays a bar chart of the values in values, using asterisks, like this:
**********************
****************************************
****************************
**************************
**************
You may assume that all values in values are positive or negative. First figure out the maximum
value in values. That value’s bar should be drawn with 40 asterisks. Shorter bars
should use proportionally fewer asterisks.

Explanation / Answer

This is actually not as scary as it looks. This will require two passes through the input values. The first pass you will identify the largest value and the smallest value. The second pass will then draw the bar chart, scaling the smallest value to zero asterisks and the largest value to one asterisk. So that being said: If you haven't seen C++ strings yet, don't worry. Instead of using the substr() method to extract the asterisks, you can do a simple "for" loop like: for( i=0; i
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