Question Please could you give the comments too and be very detailed while writing the program. CS 250 Lab Exercise 07 Main topics: Loop Statements Nested Loops Exercise This lab is designed to give you more practice working with loop statements, and in particular, nested loops. Getting Started To start this exercise, you should 1. Open eclipse and start a new Java project named Lab07 2. Add a Class (named Lab07) to this project. Problem Description . For this exercise you will be creating a small Java class that will use a user validation loop to get a number in the range of 1 to 9, inclusive. Then the program will generate a triangular shaped figure on the screen, based on the user's input. • The triangular shaped figure for an input of 1 is: 11 • The triangular shaped figure for an input of 2 is: 11 2112 • The triangular shaped figure for an input of 3 is: 11 2112 321123 • The triangular shaped figure for an input of n is: 11 2112 321123 n... 11 ...n

BWAHVC The Asker · Computer Science

Please could you give the comments too and be very detailed while writing the program.

Transcribed Image Text: CS 250 Lab Exercise 07 Main topics: Loop Statements Nested Loops Exercise This lab is designed to give you more practice working with loop statements, and in particular, nested loops. Getting Started To start this exercise, you should 1. Open eclipse and start a new Java project named Lab07 2. Add a Class (named Lab07) to this project. Problem Description . For this exercise you will be creating a small Java class that will use a user validation loop to get a number in the range of 1 to 9, inclusive. Then the program will generate a triangular shaped figure on the screen, based on the user's input. • The triangular shaped figure for an input of 1 is: 11 • The triangular shaped figure for an input of 2 is: 11 2112 • The triangular shaped figure for an input of 3 is: 11 2112 321123 • The triangular shaped figure for an input of n is: 11 2112 321123 n... 11 ...n
More
Transcribed Image Text: CS 250 Lab Exercise 07 Main topics: Loop Statements Nested Loops Exercise This lab is designed to give you more practice working with loop statements, and in particular, nested loops. Getting Started To start this exercise, you should 1. Open eclipse and start a new Java project named Lab07 2. Add a Class (named Lab07) to this project. Problem Description . For this exercise you will be creating a small Java class that will use a user validation loop to get a number in the range of 1 to 9, inclusive. Then the program will generate a triangular shaped figure on the screen, based on the user's input. • The triangular shaped figure for an input of 1 is: 11 • The triangular shaped figure for an input of 2 is: 11 2112 • The triangular shaped figure for an input of 3 is: 11 2112 321123 • The triangular shaped figure for an input of n is: 11 2112 321123 n... 11 ...n
Community Answer
GOZO7Y

  Complete JAVA code with explanation:   import java.util.Scanner;   public class Lab07{           public static void main(String[] args) {         // scanner object to read user's input         Scanner input = new Scanner(System.in);         // prompt user to input size of triangle         System.out.print("Enter size of triangle (1 to 9) inclusive: ");         int size = input.nextInt();           // if the input is not valid         while(size<1 || size >9){             System.out.println("Invalid input!! Enter again: n");             // prommpt user again to input size             System.out.print("Enter size of triangle (1 to 9) inclusive: ");             size = input.nextInt();         }         // for the size n, there will be n rows         for(int i=1; i<=size; i++){             // print the n-i spaces in ith line of triangle             for(int j=1; j<=size-i; j++){                 System.out.print(" ");             }   &# ... See the full answer