Answers for "Java program to print the character or a letter x using star"

0

Java program to print the character or a letter x using star

import java.util.*;class Main{public static void main(String args[]){ int i,j,n;Scanner sc = new Scanner(System.in);System.out.println("Enter the number to print the character");n = sc.nextInt();for(i=n;i>=1;i--){for(j=i;j<n;j++){System.out.print(" ");}for(j=1;j<=(2*i-1);j++){if(j==1 || j==(2*i-1))System.out.print("*");elseSystem.out.print(" ");}System.out.println("");} for(i=2;i<=n;i++){for(j=i;j<n;j++){System.out.print(" ");}for(j=1;j<=(2*i-1);j++){if(j==1 || j==(2*i-1))System.out.print("*");elseSystem.out.print(" ");}System.out.println("");} }}
Posted by: Guest on June-24-2021

Code answers related to "Java program to print the character or a letter x using star"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language