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

how can i change the code: public class Histogram { private int[] values; privat

ID: 664662 • Letter: H

Question

how can i change the code:

public class Histogram {
private int[] values;
private int minIndex;
private int maxIndex;
private int maxLength;

public Histogram(int[] values, int minIndex, int maxIndex, int maxLength) {
// initialize the values of the instance variables from the constructor parameters
this.values = new int [maxIndex + 1]; // allocate memory for a copy of the values array
this.minIndex = minIndex;
this.maxIndex = maxIndex;
this.maxLength = maxLength;

// step 10:
// find largest number in values array for scaling length of bars

int maxValue=values[0];
for(int i=0;i<values.length;i++)
{
if(maxValue<values[i])
{
maxValue=values[i];
}
}
  
// step 11:
// copy data from values array to this.values array while scaling to maximum length of bars
for(int i=0;i<values.length;i++)
{
this.values[i]=(values[i]*maxLength)/maxValue;
}   
}
  
// draw a horizontal bar graph
public void drawHor() {
// step 12:
// draw horizontal bar graph (one line per letter)
for(int j=0;j<26;j++)
{
for(int i=0;i<values[j];i++)
{
System.out.print("*");
}
System.out.println();
  
}
}
  
// draw a vertical bar graph
public void drawVer() {

// step 13:
// draw vertical bar graph (one column per letter)
for(int i=0;i<26;i++)
{
for(int j=0;j<values[i];j++)
{
System.out.println("*");
}
System.out.println();
}
  
}

}

=================================================================

to get a out put like

right now out put is like

***********
**
********
******
********************

*
*
*******************


****
*********
**********
***********
**
**
*******
*************
*************
************
*


*
*
*
*
*
*
*
*
*
*
*

*
*

*
*
*
*
*
*
*
*

*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*


*

*

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*

*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*

*
*

*
*

*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*
*

*
*
*
*
*
*
*
*
*
*
*
*

*

Explanation / Answer

Program Code:

import java.io.*;

import java.util.*;

public class Histogram

{

public int[] values;

public char[] letters={'a', 'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r',

's','t','u','v','w','x','y','z'};

public int minIndex;

public int maxIndex;

public int maxLength;

public static void main(String[] args)

{

int[] a={13,2,5,6,20,1,1,1,19,0,0,4,9,11,9,4,4,9,12,14,14,2,0,0,0,0};

Histogram h= new Histogram(a, 1, 26, 5);

}

public Histogram(int[] values, int minIndex, int maxIndex, int maxLength)

{

// initialize the values of the instance variables from the constructor parameters

this.values = new int [maxIndex + 1];

this.minIndex = minIndex;

this.maxIndex = maxIndex;

this.maxLength = maxLength;

// step 10:

// find largest number in values array for scaling length of bars

int maxValue=values[0];

for(int i=0;i<values.length;i++)

{

if(maxValue<values[i])

{

maxValue=values[i];

}

}

// step 11:

// copy data from values array to this.values array while scaling

//to maximum length of bars

for(int i=0;i<values.length;i++)

{

this.values[i]=(values[i]*maxLength)/maxValue;

}

// draw a horizontal bar graph

}

public void drawHor()

{

// step 12:

// draw horizontal bar graph (one line per letter)

for(int j=0;j<26;j++)

{

System.out.println(letters[j]);

for(int i=0;i<values[j];i++)

{

System.out.print("*");

}

System.out.println();

}

}

// draw a vertical bar graph

public void drawVer()

{

// step 13:

// draw vertical bar graph (one column per letter)

for(int i=20;i>=0;i--)

{

System.out.println("Count"+i);

for(int j=0;j<26;j++)

{

if(values[j]==i)

System.out.println("*");

else

System.out.println(" ");

}

System.out.println(" a b c d e f g h i j k l m n o p q r s t u v w x y z");

System.out.println();

}

}

}