Question

In: Computer Science

Using Eclipse (Pyramid) Print out the following pyramid using nested loop. 1 12 123 1234 12345...

Using Eclipse

(Pyramid) Print out the following pyramid using nested loop.

1

12

123

1234

12345

1) the source code (.java file), and
2) the screenshot of running results of each question.

Solutions

Expert Solution

Here is the answer...

Code:

class Pyramid
{
   public static void main(String[] args) {
       int n=5;                           //give n value as your wish
       for(int i=1;i<=n;i++)               //for number of rows
       {
           for(int j=1;j<=i;j++)           //printing numbers in each row
           {
               System.out.print(j);
           }
           System.out.println();           //print new line after one row
       }
   }
}

Code and Output:

If you have any doubts please COMMENT...

If you understand the answer please give THUMBS UP....


Related Solutions

C++ In this lab you will be using nested for loops to print out stars in...
C++ In this lab you will be using nested for loops to print out stars in a Diamond pattern such as this: * *** ***** ******* ********* *********** ************* *************** ************* *********** ********* ******* ***** *** * For example , if number of rows=8 then the above pattern is derived. You are to take the input for the number of lines(rows) from a file named "input_diamond" and output the pattern into both the terminal and an output file named "output_diamond".
Sarah Singleton (born July 1, 1970, and Social Security Number 473-12-1234), who lives at 123 Main...
Sarah Singleton (born July 1, 1970, and Social Security Number 473-12-1234), who lives at 123 Main Street in Mankato, MN 56001 (Blue Earth County), is single, has 20-20 vision, and has no dependents. She works 40 hours per week at a retail store in Mankato, MN, and generates $40,000 of income. Additionally, $10,000 federal income tax and $7,000 of state of MN income tax were withheld from her wages from this job, as reported on her W-2. During 2019 Sarah’s...
Print the following two patterns using nested loops. Using java. Pattern 1 13579 13579 13579 13579...
Print the following two patterns using nested loops. Using java. Pattern 1 13579 13579 13579 13579 Pattern 2 #####1 ### #12 ###123 ##1234 #12345
(C++) Write a nested loop that reads an integer n (n>0) from the keyboard and print...
(C++) Write a nested loop that reads an integer n (n>0) from the keyboard and print out "n" lines as follows: 0 0 1 0 1 2 0 1 2 3 … 0 1 2 3 … n-1
must use python Write a nested for loop that displays the following output using the same...
must use python Write a nested for loop that displays the following output using the same integer from part a:                                                     1                                                 1   2   1                                             1   2   4   2   1                                         1   2   4   8   4   2   1                                     1   2   4   8 16   8   4   2   1                                 1   2   4   8 16 32 16   8   4   2   1                             1   2   4   8 16 32 64 32 16   8   4   2   1                         1   2   4  ...
Print the following two patterns using nested loops. Pattern 1 13579 13579 13579 13579 Pattern 2...
Print the following two patterns using nested loops. Pattern 1 13579 13579 13579 13579 Pattern 2 #####1 ####12 ###123 ##1234 #12345
2) create a python program that uses a for loop and range to print out the...
2) create a python program that uses a for loop and range to print out the values 10 8 6 4 2 3) Create a python program that yses a for loop to print out ["bob","al","bert"]
3) Create a nested structure (one structure that contains another) and print out all the fields...
3) Create a nested structure (one structure that contains another) and print out all the fields in both structures. The main structure should have fields for: movie name and the year it was released. The extended structure should include the original structure as well as fields for: Lead actor, genre and runtime. In C 4) Create a structure for an employee which contains a field for: first name, last name, id and salary. Then use printf and scanf to fill...
C++ Language Implement a two-dimensional image using a nested loop. 1) Create an integer constant DIM...
C++ Language Implement a two-dimensional image using a nested loop. 1) Create an integer constant DIM and set it equal to 5. 2) Use a nested loop to print the output in terms of DIM. Example output: ***** *---* *---* *---* *****
Please use Microsoft excel. Using a Nested Loop, what is the equation to solve for letter...
Please use Microsoft excel. Using a Nested Loop, what is the equation to solve for letter grade Nested loop Student ID Grade Letter Grade 1 5 If score is Then return 2 55 Greater than 89 A 3 86 From 80 to 89 B 5 64 From 70 to 79 C 6 25 from 60 to 69 D 7 56 less than 60 F 8 58 9 99 10 90 11 28
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT