Headlines
  • <br />
  • Selamat datang di situs media w174rd.
  • Satu situs yang menjunjung tinggi kode etik ber-inofasi dan ber-informasi!!
  • http://w174rd.tk/

Program Java: Bermain Nasted for

   

 
Hosting Gratis
 

----- Print Email

Hanya sekedar pengisi waktu luang dan penghilang kejenuhan diwaktu luang. Semoga bermanfaat:

—-LEVEL 1————————————————————————————————————————————–

 

 

 

 

 

 

 

 

jawab a:

class sgta{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=1; j<=i; j++)
{
System.out.print(“* “);
}
System.out.println(“”);
}
}
}

jawab b:

class sgtb{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=1; j<=i; j++)
{
if(i==1||i==3||i==5)
{
System.out.print(“* “);
}
else if(i==2||i==4)
{
System.out.print(“# “);
}
}
System.out.println(“”);
}
}
}

jawab c:

class sgtc{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=5; j>=i; j–)
{
System.out.print(“* “);
}
System.out.println(” “);
}
}
}

jawab d:

class sgtd{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=5; j>=i; j–)
{
if(i==1||i==3||i==5)
{
System.out.print(“# “);
}
else if(i==2||i==4)
{
System.out.print(“* “);
}
}
System.out.println(“”);
}

}
}

jawab e:

class sgte{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=1; j<=i; j++)
{
if(j==1||j==3||j==5)
{
System.out.print(“* “);
}
else if(j==2||j==4)
{
System.out.print(“# “);
}
}
System.out.println(“”);
}
}
}

jawab f:

class sgtf{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=5; j>=i; j–)
{
if(j==1||j==3||j==5)
{
System.out.print(“# “);
}
else if(j==2||j==4)
{
System.out.print(“* “);
}
}
System.out.println(“”);
}
}
}

jawab g:

class sgtg{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=1; j<=i; j++)
{
System.out.print(j +” “);
}
System.out.println(“”);
}
}
}

jawab h:

class sgth{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=i; j>=1; j–)
{
System.out.print(j +” “);
}
System.out.println(“”);
}
}
}

jawab i:

class sgti{
public static void main(String[] args){
for(int i=5; i>=1; i–)
{
for(int j=i; j<=5; j++)
{
System.out.print(j +” “);
}
System.out.println(“”);
}
}
}

jawab j:

class sgtj{
public static void main(String[] args){
for(int i=5; i>=1; i–)
{
for(int j=5; j>=i; j–)
{
System.out.print(j +” “);
}
System.out.println(“”);
}
}
}

jawab k:

class sgtk{
public static void main(String[] args){
for(int i=5; i>=1; i–)
{
for(int j=1; j<=i; j++)
{
System.out.print(j +” “);
}
System.out.println(“”);
}
}
}

jawab l:

class sgtl{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=i; j<=5; j++)
{
System.out.print(j +” “);
}
System.out.println(“”);
}
}
}

jawab m:

class sgtm{
public static void main(String[] args){
for(int i=5; i>=1; i–)
{
for(int j=i; j>=1; j–)
{
System.out.print(j +” “);
}
System.out.println(“”);
}
}
}

jawab n:

class sgtn{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=i; j>=1; j–)
{
System.out.print(j+” “);
}

for(int j=2; j<=(6-i); j++)
{
System.out.print(j+” “);
}
System.out.println(“”);
}
}
}

jawab o:

class sgto{
public static void main(String[] args){
for(int i=5; i>=1; i–)
{
for(int j=i; j<=5; j++)
{
System.out.print(j+” “);
}

for(int j=4; j>=(6-i); j–)
{
System.out.print(j+” “);
}
System.out.println(“”);
}
}
}

 

 

—-LEVEL 2————————————————————————————————————————————–

 

 

 

 

 

jawab a:

class sgt2a{
public static void main(String[] args){
for(int i=5; i>=1; i–)
{
for(int j=i; j>=2; j–)
{
System.out.print(” “);
}

for(int j=5; j>=i; j–)
{
System.out.print(“* “);
}
System.out.println(“”);
}
}
}

jawab b:

class sgt2b{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=2; j<=i; j++)
{
System.out.print(” “);
}

for(int j=5; j>=i; j–)
{
System.out.print(“* “);
}
System.out.println(“”);
}
}
}

jawab c:

class sgt2c{
public static void main(String[] args){
for(int i=5; i>=1; i–)
{
for(int j=i; j>=2; j–)
{
System.out.print(” “);
}

for(int j=1; j<=(6-i); j++)
{
System.out.print(j+” “);
}
System.out.println(“”);
}
}
}

jawab d:

class sgt2d{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=2; j<=i; j++)
{
System.out.print(” “);
}

for(int j=5; j>=i; j–)
{
System.out.print(j+” “);
}
System.out.println(“”);
}
}
}

jawab e:

class sgt2e{
public static void main(String[] args){
for(int i=5; i>=1; i–)
{
for(int j=i; j>=2; j–)
{
System.out.print(” “);
}

for(int j=5; j>=i; j–)
{
System.out.print(j+” “);
}
System.out.println(“”);
}
}
}

jawab f:

class sgt2f{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=2; j<=i; j++)
{
System.out.print(” “);
}

for(int j=1; j<=(6-i); j++)
{
System.out.print(j+” “);
}
System.out.println(“”);
}
}
}

jawab g:

class sgt2g{
public static void main(String[] args){
for(int i=1; i<=5; i++)
{
for(int j=2; j<=i; j++)
{
System.out.print(” “);
}

for(int j=1; j<=(12-(i*2)); j=j+2)
{
System.out.print(j+” “);
}
System.out.println(“”);
}
}
}

 

 

—-LEVEL 3————————————————————————————————————————————–

 

 

 

 

 

 

 

 

 

 

 

 

CAN DIKERJAKEUN, LOBA TUGAS UY..

 

——-Catatan:———————————-

1. Jadikan Thread ini sebagai tambahan referensi dalam belajar. karena bagai manapun juga, logika seseorang itu tidak bisa di-Copy-Paste.

2. Jika ada kesalahan tolong dikonfirmasi.

Konten Terkait:

  1. UAS Dasar Pemrograman C++, 8 Juni 2011

    1. Masukkan kalimat, hitung jumlah karakter yang ada di kalimat....

 
 
 

Leave a Reply

 

*



Hosting Gratis