Assignement: Nested Loops to create a Multiplication Table
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: MultiplicationTable
/// File Name: MultiplicationTable.java
/// Date Finished: 5/2/2016
public class MultiplicationTable
{
public static void main( String[] args )
{
System.out.println("x | 1 2 3 4 5 6 7 8 9" );
System.out.println("==+==================================================" );
for ( int y = 1; y <= 12; y++ )
{
System.out.print( y + " | ");
for ( int x = 1; x <= 9; x++ )
{
int c = x*y;
if ( c < 10 )
System.out.print( c + " " );
else if ( c > 10)
System.out.print( c + " " );
}
System.out.print("\n");
}
}
}
Picture of the output