Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Javascript (https://www.askmehelpdesk.com/forumdisplay.php?f=452)
-   -   Need help for java code... (https://www.askmehelpdesk.com/showthread.php?t=772326)

  • Oct 22, 2013, 03:28 PM
    mac22k
    Need help for java code...
    Method called printGraph() that takes as a parameter an array of integers. Each
    integer will be between 0 and 100. The method should print a horizontally oriented bar graph of the values, using ‘=’ characters to produce bars. Each value should be divided
    By 10 and that many equals characters printed (so the maximum length of a bar will be 10 characters for a value of 100).
    The actual value of the bar should be printed following a space at the end of each line.
    So, for example, if the argument to printGraph() is { 14, 65, 39, 99 } then the output should look like this
    = 14
    ====== 65
    === 39
    ========= 99

    My answer was

    int printGraph(int [] args)
    {
    int size=0;
    int length, j;
    For(length = 1; length <= size; length++){
    For(j = 1; j <= length; j++)
    Print("=");
    Println(size);` ` `

    }
    Return length;
    }
    }

    Help me with codas...

  • All times are GMT -7. The time now is 02:51 PM.