0

How to print this pattern in java

$$ $ $ $ $ $$

27th Aug 2022, 2:07 AM
Nabo Fasith
Nabo Fasith - avatar
3 Respostas
+ 3
If you don't need user input, it's a fairly easy thing to do. Printline 1 ($$) Printline 2 ($ $) Printline 3 ($ $) Printline 4 ($$)
27th Aug 2022, 8:30 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
import java.util.*; // Compiler version JDK 11.0.2 class Dcoder { public static void main(String args[]) { //System.out.println("Hello, Dcoder!"); int n = 4; for(int i=1; i<=4; i++){ for(int j=1; j<=4; j++){ if((i==1&&(j>=1&&j<=n))||(i==n&&(j>=1&&j<=n))||j==1||j==n){ System.out.print("
quot;); } else{ System.out.print(" "); } } System.out.println(); } } }
28th Aug 2022, 5:18 PM
Geerbani Pal Shashi
Geerbani Pal Shashi - avatar