Embed presentation
Download to read offline
![import java.util.Scanner;
class grid3 {
public static void main(String[]args){
Scanner scanner = new Scanner(System.in);
int x = 10;
while (x >= 1) {
//
int y = x;
while ( x >= x - 6) {
System.out.println( y + "t");
y = y - 2;
}
System.out.println();
x = x - 1;
}
scanner.close();
}
}](https://image.slidesharecdn.com/123-160307154932/85/123-1-320.jpg)
This Java code uses nested while loops to print a descending triangular grid of numbers. It takes user input, initializes a variable x to 10, then uses the outer while loop to decrement x down to 1, printing each row. The inner while loop prints each number in the row, decrementing the variable y by 2 until it reaches the value of x minus 6, then it prints a new line before continuing the outer loop.
![import java.util.Scanner;
class grid3 {
public static void main(String[]args){
Scanner scanner = new Scanner(System.in);
int x = 10;
while (x >= 1) {
//
int y = x;
while ( x >= x - 6) {
System.out.println( y + "t");
y = y - 2;
}
System.out.println();
x = x - 1;
}
scanner.close();
}
}](https://image.slidesharecdn.com/123-160307154932/85/123-1-320.jpg)