+ 1

i dont know what should i do

This code is the first digit numbers that are printed as follows. I want my numbers to be in five rows and eight columns.what should I do? public static void main(String[] args) { // TODO code application logic here int number_of_prime = 40; int number_of_prime_line = 8; int count = 0; int number = 2; System.out.println(" the first 40 numbers are "); while (count < number_of_prime) { boolean isPrime = true; for (int divisor = 2; divisor <= number / 2; divisor++) { if (number % divisor == 0) { isPrime = false; break; } } if (isPrime) { count++; System.out.println(number + " "); } number++; } } }

19th Jun 2020, 11:47 AM
saina
1 Odpowiedź
0
You want to format the output, right? Therefore you would have to write line by line and write eight values per line. Use print to write in the same line and println to continue output in next line.
19th Jun 2020, 6:22 PM
Sandra Meyer
Sandra Meyer - avatar