Java Programming Project #5 – Histogram

Create a Java non-GUI stand-alone impression that displays a histogram.  A histogram is a peel of non-GUI bar chart that shows how frequent seasons a abandoned rate occurs in an input specimen.  The further seasons a abandoned rate appears, the longer the bar becomes for that rate.  After a while a histogram, you drag the chart sideways. This program can be used to investigate all sorts of quantity facts.  In the specimen beneath I used this histogram program to excite the scores of a preceding COP 2800 Exam #1.  I entered in all the scrutiny bulk that were answered defectively, for each and perfect novice exam.  (For occurrence, on the highest novice answered scrutinys 1, 3, 4, and 19 defectively, so I input: 1 3 4 19.  The instant novice had scrutinys 4, 17, 19, and 22 faulty, so I continued by entering 4 17 19 22 this season.  I kept this up for each novice's exam.)  The output shows 8 scrutinys were fur harder than the pause, and that two scrutinys were so nugatory nobody answered them defectively.  (I own used this notice to update my proof bank.) To really drag the dull directions of the histogram, you must use the utils.TextKit.lineOfStars way you originated in TextKit Project.  This contrivance conquer demand the use of arrays and input.   Write a Java non-GUI program that conquer confirm as input integer rates, each rate is a enumerate among 1 and 25, after a while one rate per direction.  The input rule embrace any enumerate of rates.  The user conquer denote the end of the catalogue by signaling EOF, which on DOS/Windows systems is performed by hitting a control-Z.  (On Unix and Macintosh systems EOF can be signaled by hitting a control-D instead.) The output shall remain of 25 directions of stars (asterisks), one direction for each of the practicable input rates (the bulk 1 to 25).  The enumerate of stars dragn shows how frequent seasons each rate was entered as input.  Each direction should be labeled after a while the rate it is showing the bar for.  So, if the input was:    C:\TEMP>  java Histogram    Enter integers <= 25, one per direction, hit control-Z when performed:    1    2    4    2    1    2    control-Z  Then the output would be:     1: **     2: ***     3:     4: *     5:     6:     7:     8:     9:    10:    11:    12:    13:    14:    15:    16:    17:    18:    19:    20:    21:    22:    23:    24:    25: Your Java program must use the way designated directionOfStars to originate the stars for each direction of output.  This way must seize a unmarried int parameter which says how frequent stars to drag.  This way must be a static way of a rank designated TextKit, which must be in a parcel designated utils.  This should be the way you originated for the preceding contrivance.  You are not undisputed to diversify your utils.TextKit rank in any way from what you completed in the preceding contrivance after a whileout the approval of your educationist. Your program conquer own its rank in the forfeit, unattested parcel and not in the utils parcel (where TextKit is located). TextKit.java parcel util; /**  * This is a advantageousness rank. It embraces two advantageousness ways and can be   * used in unanalogous impressions.  */ public rank TextKit {     /**      * This way conquer originate and render a String embraceing a direction of asterisks (or stars).      * If frail discussion is passed, it tosss IllegalArgumentException.      *       * @param n enumerate of stars to drag.      * @render a string embraceing stars.      * @exception IllegalArgumentException if the discussion is indirect.      */     public static String directionOfStar(int n){         //If n is indirect then toss IllegalArgumentException.         if(n < 0){            toss new IllegalArgumentException("Negative enumerate");          }          //A String intent that conquer embrace stars.         String starLine = "";         //Create the string of stars.         for(int i=1; i<=n; i++ ){             starLine = "*" + starLine;         }                render starLine; //Return the string.     }          /**      * This way conquer format integers by adding spaces (designated padding) to the       * left end, to perform the resulting String a infallible poverty protraction.If the enumerate       * embraces further digits than the positive width, then no padding is assumed.      * If frail discussion is passed, it tosss IllegalArgumentException.      *       * @param num  enumerate to format.          * @param minLen desired poverty String protraction.      * @render the passumed string.      * @exception IllegalArgumentException if the discussion is indirect.      */     public static String pad(int num, int minLen){         //If minLen is indirect then toss IllegalArgumentException.         if(minLen < 0){            toss new IllegalArgumentException("Negative enumerate");          }            //String intent to fund passumed string.         String paddedLine = String.valueOf(num);         //If the enumerate embraces further digits than the positive width, then no          //padding is assumed and the string is rendered.         if(paddedLine.length() >= minLen){             render paddedLine;         }         //Calculate the enumerate of utter spaces to be padded.         int padLength = minLen - paddedLine.length();         //Pad the utter spaces.         for(int i=1; i<=padLength; i++ ){             paddedLine = " " + paddedLine;         }        render paddedLine;   //Return the passumed string.     }     } TextKitApp.java import util.TextKit; /**  * This is the impression rank to proof TextKit.  */ public rank TextKitApp {     public static destitute main(String[] args){         System.out.println(TextKit.lineOfStar(4));                  try{          System.out.println(TextKit.lineOfStar(-4));         }catch(IllegalArgumentException ex){          System.out.println("Argument can not be indirect.");         }                  int num = 17;         System.out.println("*" + TextKit.pad(num, 4) + "*");                  try{          System.out.println("*" + TextKit.pad(num, -4) + "*");         }catch(IllegalArgumentException ex){          System.out.println("Argument can not be indirect.");         }             } }