22 * Examples from Chapter 7.
33 */
44public class Tables {
5-
5+
66 public static void example () {
77 int i = 1 ;
88 while (i < 10 ) {
@@ -11,7 +11,7 @@ public static void example() {
1111 i = i + 1 ;
1212 }
1313 }
14-
14+
1515 public static void example2 () {
1616 int i = 1 ;
1717 while (i < 10 ) {
@@ -20,7 +20,7 @@ public static void example2() {
2020 i = i + 1 ;
2121 }
2222 }
23-
23+
2424 public static void example3 () {
2525 final double LOG2 = Math .log (2 );
2626 int i = 1 ;
@@ -30,7 +30,7 @@ public static void example3() {
3030 i = i * 2 ;
3131 }
3232 }
33-
33+
3434 public static void example4 () {
3535 int i = 1 ;
3636 while (i <= 6 ) {
@@ -39,7 +39,7 @@ public static void example4() {
3939 }
4040 System .out .println ();
4141 }
42-
42+
4343 public static void printRow () {
4444 int i = 1 ;
4545 while (i <= 6 ) {
@@ -48,7 +48,7 @@ public static void printRow() {
4848 }
4949 System .out .println ();
5050 }
51-
51+
5252 public static void printRow2 (int n ) {
5353 int i = 1 ;
5454 while (i <= 6 ) {
@@ -57,31 +57,31 @@ public static void printRow2(int n) {
5757 }
5858 System .out .println ();
5959 }
60-
60+
6161 public static void example5 () {
6262 int i = 1 ;
6363 while (i <= 6 ) {
6464 printRow2 (i );
6565 i = i + 1 ;
6666 }
6767 }
68-
68+
6969 public static void printTable () {
7070 int i = 1 ;
7171 while (i <= 6 ) {
7272 printRow2 (i );
7373 i = i + 1 ;
7474 }
7575 }
76-
76+
7777 public static void printTable2 (int rows ) {
7878 int i = 1 ;
7979 while (i <= rows ) {
8080 printRow2 (i );
8181 i = i + 1 ;
8282 }
8383 }
84-
84+
8585 public static void printRow3 (int n , int cols ) {
8686 int i = 1 ;
8787 while (i <= cols ) {
@@ -90,66 +90,66 @@ public static void printRow3(int n, int cols) {
9090 }
9191 System .out .println ();
9292 }
93-
93+
9494 public static void printTable3 (int rows ) {
9595 int i = 1 ;
9696 while (i <= rows ) {
9797 printRow3 (i , rows );
9898 i = i + 1 ;
9999 }
100100 }
101-
101+
102102 public static void printTable4 (int rows ) {
103103 for (int i = 1 ; i <= rows ; i = i + 1 ) {
104104 printRow3 (i , rows );
105105 }
106106 }
107-
107+
108108 public static void printRow4 (int n , int cols ) {
109109 int i ;
110110 for (i = 1 ; i <= cols ; i = i + 1 ) {
111111 System .out .printf ("%4d" , n * i );
112112 }
113113 System .out .println (i );
114114 }
115-
115+
116116 public static void main (String [] args ) {
117117 System .out .println ("example" );
118118 example ();
119-
119+
120120 System .out .println ("example2" );
121121 example2 ();
122-
122+
123123 System .out .println ("example3" );
124124 example3 ();
125-
125+
126126 System .out .println ("example4" );
127127 example4 ();
128-
128+
129129 System .out .println ("example5" );
130130 example5 ();
131-
131+
132132 System .out .println ("printRow" );
133133 printRow ();
134-
134+
135135 System .out .println ("printRow2" );
136136 printRow2 (6 );
137-
137+
138138 System .out .println ("printTable" );
139139 printTable ();
140-
140+
141141 System .out .println ("printTable2" );
142142 printTable2 (6 );
143-
143+
144144 System .out .println ("printRow3" );
145145 printRow3 (6 , 6 );
146-
146+
147147 System .out .println ("printTable3" );
148148 printTable3 (6 );
149-
149+
150150 System .out .println ("printRow4" );
151151 printRow4 (6 , 6 );
152-
152+
153153 System .out .println ("printTable4" );
154154 printTable4 (6 );
155155 }
0 commit comments