Monday , December 18 2017
Home / Blue J / java program for pattern#6

java program for pattern#6

Java program for printing the following pattern:
This program also have indentation. Indentation required depends on the output needed and here indentation requires is: for row 1:  total 4 spaces and then 1 start row 2: total 3 spaces and 3 stars row 3: total 5 spaces and 5 stars……. So on  So here spacing is decreasing by 1. Stars/asterisk increases by two starting with 1.
So step 1: print spacing (with decreasing loop variable)
step 2: print asterisk (with increasing loop variable)
class format5
public static void main(String args[])
int i,j,k=1;                                                                            

for(j=5;j>=i;j--)    // printing the space which is dependent on i;
System.out.print(' '); 

for(j=1;j<2*i;j++)   /for printg the required asterisk/star



Tags: java program for pattern making,  program for star pattern in java,bluej, making star pattern in java/bluej/c/c++

Also See:   Java Program to find Mobius Function of number

Check Also

Java program to implement polymorphism

Java program to implement polymorphism: Polymorphism is a technique in java with which you can ...

Leave a Reply

Your email address will not be published. Required fields are marked *