Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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("");} }}
Source by inlarn.com #
 
PREVIOUS NEXT
Tagged: #Java #program #print #character #letter #star
ADD COMMENT
Topic
Name
1+3 =