Write java program to print the following shape N lines.
*
* *
* * *
* * * *
* * * * *
* * * * * *
Input: N
Output: The printed shape
/** * @fileName Shape.java * @author * @since 21/3/17 */ import java.util.Scanner; public class Shape { public static void main(String[] args) { //creating Scanner object to read input from keyboard Scanner console = new Scanner(System.in); System.out.print("Enter N:"); int N = console.nextInt(); //store the user input in variable N for(int i=1;i<=N;i++){ for(int j=1;j<=i;j++){ System.out.print("*"); } System.out.println(); } } }
output:
Get Answers For Free
Most questions answered within 1 hours.