in Java please use only while loops Based on nested while lo
in Java please use only while loops.
Based on nested while loops, write a program that will cycle through an imaginary seven rows (1 through 7) and six columns (A through F) to produce the output shown below. For the output, indicate what row and column is referenced—along with the product of the row multiplied by the ASCII code for the letter of the column. This is a totally useless, arbitrary thing to do. The product of the ASCII codes has no special meaning; it\'s just practice to get the code to do it. Use a void() method to produce each line of output. Pass the method the current row and column; have the method calculate the product (row x col) and display it as shown below. Your row counter variable is pretty straightforward—it will need to be an int and it will range from 1 to 7. Columns are a little trickier but this should make it simple: recall, characters are stored internally as int values (ASCII codes) so addition and subtraction works against the underlying ASCII value if you cast your fishing line appropriately. Example output
Row 1 Col A: 65
Row 1 Col B: 66
Row 1 Col C: 67
Row 1 Col D: 68
Row 1 Col E: 69
Row 1 Col F: 70
Row 2 Col A: 130
Row 2 Col B: 132
Row 2 Col C: 134
…
…
Row 6 Col C: 402
Row 6 Col D: 408
Row 6 Col E: 414
Row 6 Col F: 420
Row 7 Col A: 455
…
Row 7 Col F: 490
Solution
/**
* @author
*
*/
public class GenerateCycle {
/**
* @param args
*/
public static void main(String[] args) {
int i = 1;
while (i <= 7) {
char ch = \'A\';
while (ch <= \'F\') {
System.out.println(\"Row \" + i + \" Col \" + ch + \": \"
+ calculate(i, ch));
ch++;
}
i++;
}
}
/**
* @param row
* @param col
* @return
*/
public static int calculate(int row, int col) {
return row * col;
}
}
OUTPUT:
Row 1 Col A: 65
Row 1 Col B: 66
Row 1 Col C: 67
Row 1 Col D: 68
Row 1 Col E: 69
Row 1 Col F: 70
Row 2 Col A: 130
Row 2 Col B: 132
Row 2 Col C: 134
Row 2 Col D: 136
Row 2 Col E: 138
Row 2 Col F: 140
Row 3 Col A: 195
Row 3 Col B: 198
Row 3 Col C: 201
Row 3 Col D: 204
Row 3 Col E: 207
Row 3 Col F: 210
Row 4 Col A: 260
Row 4 Col B: 264
Row 4 Col C: 268
Row 4 Col D: 272
Row 4 Col E: 276
Row 4 Col F: 280
Row 5 Col A: 325
Row 5 Col B: 330
Row 5 Col C: 335
Row 5 Col D: 340
Row 5 Col E: 345
Row 5 Col F: 350
Row 6 Col A: 390
Row 6 Col B: 396
Row 6 Col C: 402
Row 6 Col D: 408
Row 6 Col E: 414
Row 6 Col F: 420
Row 7 Col A: 455
Row 7 Col B: 462
Row 7 Col C: 469
Row 7 Col D: 476
Row 7 Col E: 483
Row 7 Col F: 490


