Write this program in simple java. I am a beginner in java. Please donot use bre
ID: 3716759 • Letter: W
Question
Write this program in simple java. I am a beginner in java. Please donot use break statements and please write the comments so i could understand your code
NoNot a problem from the book, but it uses multidimensional arrays.Pascal’s triangle is a chart of numbers where each row is created from the values on the row above it.Each row begins and ends with 1, and additional numbers are the sum of the two numbers above it.
Example of first five rows:1
Your job is to create the first few rows of Pascal’s triangle in a multidimensional array and output it to the screen.You can line the columns up to the left to make it easier to store and/or output.I want you to create each row from the row above it, and allow the user to tell you how many rows to create.
Note that each row will have a different length.The first row should only be able to hold 1 value, which is 1.The second row should only be able to hold 2 values, which should be 1 and 1.Etc.If the user types in 10, do not just create a 10 x 10 array and then leave spots blank.
This program displays Pascal’s triangle. How many rows would you like to see?
>>>9
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1
Explanation / Answer
Please find my code.
Output:
>>> 9
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
Process finished with exit code 0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.