How to Print a specific amount of spaces per line in Java
<p>I am trying to get a Java program to print a specific amount of spaces per line and then drop down to continue the list. I am finding all prime numbers in a user specified range and then printing out the number of primes in the range and the prime numbers themselves. Anytime the program finds a number that is not a prime number it should print a - . So far, I have: </p>

<p>import java.util.Scanner;</p>

<p>public class PrimeNums {</p>

<pre><code>public static void main(String[] args) {
    Scanner keyboard= new Scanner(System.in);
    int startingVal;
    int endingVal;
    int index;
    int currNum = 2;
    boolean prime;
    int count=0;

    //***  Input  ***

    System.out.println("Enter the Starting Number of the Range: ");
    startingVal = keyboard.nextInt();
    System.out.println("Enter the Ending Value of the Range: ");
    endingVal = keyboard.nextInt();



    //*** Checks for Parameters  ***

    while(startingVal&gt;1000||startingVal%10!=0){
        System.out.println("Starting Value was not evenly divisible by 10. Reenter Starting Value: ");
        startingVal= keyboard.nextInt();
    }
    while(startingVal&gt;=endingVal||endingVal%10!=0||endingVal&gt;1000){
        System.out.println("Ending Value was less than Starting Value or Did Not Follow Guideline. Reenter Ending Value: ");
        endingVal=keyboard.nextInt();
    }


    //***  Stores Checked Variables  ***

    int range = (endingVal);
    int[] primeArray = new int[10];

    //*** Checks for all Prime Numbers  ***

    for(index=startingVal; index&lt;range; index++){

        if(index==1||index%2==0||index%3==0||index%4==0||index%5==0||index%6==0||index%7==0||index%8==0||index%9==0||index%10==0){
            System.out.print("-");
        }else{
            count++;
            System.out.print(index);
        }
    }
    System.out.println("There are " + count + " Prime Numbers in this range.");
}


}
</code></pre>

<p>So far, this program finds all the prime numbers within the range and prints them out. However, I need the code to print out in sets of 10. Something like this:
Range here is: 70-200.</p>

<hr>

<p>71  -  73  - - - -   - 79  - | 80</p>

<ul>
<li><ul>
<li>83  - - - -   - 89  - | 90</li>
</ul></li>
<li><ul>
<li><ul>
<li><ul>
<li><ul>
<li><ul>
<li>97  - -   - | 100</li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul>

<p>101 -  103 - - - 107 - 109 - | 110</p>

<ul>
<li><ul>
<li>113 - - - -   - -   - | 120</li>
</ul></li>
<li><ul>
<li><ul>
<li><ul>
<li><ul>
<li><ul>
<li>127 - -   - | 130</li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul>

<p>131 -  -   - - - 137 - 139 - | 140</p>

<p><ul>
<li><ul>
<li><ul>
<li><ul>
<li><ul>
<li><ul>
<li><ul>
<li><ul>
<li>149 - | 150</li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
151 -  -   - - - 157 - -   - | 160</p>

<ul>
<li><ul>
<li>163  - - - 167 - -   - | 170</li>
</ul></li>
<li><ul>
<li>173  - - - -   - 179 - | 180</li>
</ul></li>
</ul>

<p>181 - -    - - - -   - -   - | 190</p>

<p>191 - 193  - - - 197 - 199 - | 200</p>

<hr>

<p>There are 27 prime numbers between 70 and 200</p>
