Answer to Question #252979 in Java | JSP | JSF for Amadix

Question #252979

Write a program which inputs a positive integer n and outputs an n line high triangle of '*' characters whose right-angle is in the bottom left corner. For example, if 5 is input the output should be


1
Expert's answer
2021-10-18T18:26:58-0400
import java.util.*;


class Main
{
	public static void main(String args[])
	{		
		int x,y,n;
		Scanner input = new Scanner(System.in);
    		System.out.print("Enter a positive interger n: ");
    		n = input.nextInt();
    
		for(x=1;x<=n;x++)
    		{
        		for(y=1;y<=x;y++)
        		{
            			System.out.print("* ");
        		}
        		System.out.println("");
    		}	
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS