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
Given a non-negative integer n, write a program, name it Triangle that will return the number of blocks it takes to make
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am