Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Copy the skeleton of code below into your answer. Then in the space indicated, add your own code to prompt the user for a number. If the number is greater than 0 it should print a triangle of that...

1 answer below »

Copy the skeleton of code below into your answer. Then in the space indicated, add your own code to prompt the user for a number. If the number is greater than 0 it should print a triangle of that size as shown below. If the number is less than or equal to 0 it should print nothing. See the transcripts below for some sample runs of this code:

Enter a number: 3
***
**
*

A second run of this program with different input might look like this:

Enter a number: 5
*****
****
***
**
*

A third run of this program with a zero or negative input might look like this:

Enter a number: -12

Use the skeleton of the main method below to write your code.

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// TODO: Your code below this line
input.close();
}

Answered Same Day Sep 29, 2021

Solution

Neha answered on Sep 30 2021
138 Votes
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in);
System.out.print("Enter a number: ");
int rows= sc.nextInt();
for (int i= rows-1; i>=0 ; i--)
{
for...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here