Answer to Question #252999 in Java | JSP | JSF for NUCHO

Question #252999

: 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


1
Expert's answer
2021-10-18T18:28:56-0400

SOLUTION CODE FOR THE QUESTION


package com.company;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
   // write your code here
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a positive number: ");
        int positive_number = sc.nextInt();
        for(int i=0; i<positive_number; i++){
            for(int j=0; j<=i; j++){
                //print the character and a space for good formatting
                System.out.print("* ");
            }
            //Go in newline
            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