Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>You have errors in your code</strong> </p> <p>Here is your updated code</p> <pre><code>public class Marks { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int[] array = new int[23]; int num = 0; int count = 0; int total = 1; System.out.println ("Enter students marks in the range 0 to 100\n"); loop: for (count = 0; count &lt;= 20; count++) { System.out.println("Enter a number:"); num = scan.nextInt(); if (num &lt; 0 || num &gt; 100) { break loop; } array[count] = num; total = count+1; } System.out.println ("How many times a number between 0-100 occur."); String[] asterisk = {"0- 29 | ", "30- 39 | ","40- 69 | ", "70- 100 | "}; //4 strings for (count = 1; count &lt;= total; count++) { num=array[count]; if (num &gt;=0 &amp;&amp; num&lt;=29) asterisk [0] +="*"; else if (num&gt;29 &amp;&amp; num&lt;=39) asterisk[1] +="*"; else if (num&gt;39 &amp;&amp; num &lt;=69) asterisk[2] +="*"; else if (num &gt;69 &amp;&amp; num &lt;=100) asterisk[3] +="*"; } for (count =0;count &lt; 4;count++) System.out.println(asterisk[count]); System.out.println("The total amount of students is " + total); } } </code></pre> <p><strong>Here is the output</strong> </p> <pre><code>Enter students marks in the range 0 to 100 Enter a number: 1 Enter a number: 10 Enter a number: 50 Enter a number: 111 How many times a number between 0-100 occur. 0- 29 | ** 30- 39 | 40- 69 | * 70- 100 | The total amount of students is 3 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload