Problem:
Write an application that displays the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form System.out.print( '*' ); which causes the asterisks to print side by side. A statement of the form System.out.println(); can be used to move to the next line. A statement of the form System.out.print( ' ' ); can be used to display a space for the last two patterns. There should be no other output statements in the program. [Hint: The last two patterns require that each line begin with an appropriate number of blank spaces.]
Shape (a):
public class Exercice2a { public static void main (String[] args) { for (int count =0; count < 10; count++) { for (int j=0; j < count+1; j++) System.out.print("*"); System.out.println(); } } }
Shape (b):
public class Exercice2b { public static void main (String[] args) { for (int count =11; count >= 0; count--) { for (int j=0; j < count-1; j++) System.out.print("*"); System.out.println(); } } }
Shape (c):
public class Exercice2c { public static void main (String[] args) { for(int count = 0; count < 10; count++) { for(int index=1; index < count+1; index++) System.out.print(" "); for(int star=10; star > count; star--) System.out.print("*"); System.out.println(); } } }
Shape (d):
public class Exercice2d { public static void main (String[] args) { for(int count = 10; count > 0; count--) { for(int index=0; index < count-1; index++) System.out.print(" "); for(int star=10; star > count-1; star--) System.out.print("*"); System.out.println(); } }
how can i get this program, java asterisk forming a square
ReplyDelete* * * * *
* *
* *
* *
* *
* * * * *
how to get this
ReplyDelete*** ***
** **
* *
how to print this
ReplyDelete********
*** ***
** **
* *
* *
** **
*** ***
********
The run of the mill or disconnected printing process. ThisVSL Print
ReplyDeletePlease solution
ReplyDelete*****
***
*
******
ReplyDelete****
**
Great article with excellent idea!Thank you for such a valuable article. I really appreciate for this great information.. every door direct mail® postcard prints at 55printing
ReplyDeleteWhen compared to the typical/offline strategy this method provides a saving of 47%, however the printing quality is low and in the end, printing 250 sets at the office costs more than printing 1000 sets at an online printer.
ReplyDeletemedijo
How can do this please help me(odd no. only)
ReplyDelete* * * * *
* * *
* * * * *
* * *
* * * * *
If you searching for the Avionics Displays , then they directly reach iDisplays. Here you people get up-to-date with the professional technical sales team. All of them explain everything about their displays deeply. Well, this display meets the precise technical and environmental specifications of the customer requirements.
ReplyDelete