Created
October 4, 2015 12:11
-
-
Save LukeMcNemee/3f4ec9f19c642653dab3 to your computer and use it in GitHub Desktop.
Java For cycles, print small multiplication table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Multiples { | |
public static void printMultiples(int max){ | |
System.out.print(" | "); | |
for(int i = 1; i <= max; i++){ | |
System.out.print( i + " "); | |
} | |
System.out.println(""); | |
System.out.print( "--|--"); | |
for(int i = 1; i <= max; i++){ | |
System.out.print( "---"); | |
} | |
System.out.println(""); | |
for(int i = 1; i <= max; i++){ | |
System.out.print( i + " | "); | |
for(int j = 1 ; j <= max; j++){ | |
System.out.print(i*j + " "); | |
if(i*j < 10){ | |
System.out.print(" "); | |
} | |
} | |
System.out.println(""); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment