I created an ASCII table in Java that prints 10 characters per line, and goes from '!' to '~'. Everything worked great except for the first row, which only printed nine characters (or printed a space?). Does anyone see a syntax or processing problem that would be causing this? It only happened on the first row. Note: I was only allowed to use one for loop.
public class AsciiChars {
public static void main(String[]args) {
int count = 0; // initialize counter variable
for (int ascii = 33; ascii < 127; ascii++, count++) { //conditions for the for loop
if ((ascii - 12) % 10 == 0){ //formula needed to create the rows. The end char in each row,
// minus 12 (42, 52, 62, etc), will be divisible by 10, thus ending the row.
System.out.println("\n"); // Print a new line after every row.
} //end if
System.out.print((char)ascii + " "); //casting the ascii int to a char and adding a space after every char
}//end for loop
}//end main
}//end class