Page 1 of 1

Given a non-negative integer n, write a program, name it Triangle that will return the number of blocks it takes to make

Posted: Mon Mar 21, 2022 4:42 pm
by answerhappygod
Given a non-negative integer n, write a program,
name it Triangle that will return the number of blocks it takes to
make a triangle with n.
Use the Scanner method to get user input for n
Ex.
n = 1 returns: 1 block is needed to make a triangle with 1
row.
n = 2 returns: 3 blocks are needed to make a triangle with 2
rows.
n = 3 returns: 6 blocks are needed to make a triangle with 3
rows. And so on.
Java