// NestedWhileLoops.java
// Application demoing nested while loops summing an array
import javax.swing.*;

public class NestedWhileLoops {
	public static void main( String args[ ] ) {

		// hard code the sales array
		int sales[ ][ ] = { { 10, 5, 3, 2 }, { 20, 4, 8, 4 }, { 6, 10, 7, 10 } };
		int total = 0;

		// sum the array
		int row = 0;
		while ( row <= 2 ) {
			int col = 0;
			while ( col <= 3 ) {
				total += sales[ row ][ col ];
				col++;
			}
			row++;
		}
	
		JOptionPane.showMessageDialog( null, "The total sales is " + total, "Sum of Sales Array", JOptionPane.INFORMATION_MESSAGE );

		// terminate the program
		System.exit( 0 );
	}
}