Program menampilkan pola :
a. *****
****
***
**
*
P
E N Y E L E S A I A N :
package Pola1;
import java.util.*;
public class Main {
public static void main(String[] args) {
System.out.println("Program
Menampilkan Pola");
System.out.println("______________________________");
int n;
int i;
int j;
Scanner scan = new Scanner (System.in);
System.out.print ("Banyak Pola = ");
n = scan.nextInt();
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
H A S I L :
b. *
**
***
****
*****
P
E N Y E L E S A I A N :
package Pola2;
import java.util.*;
public class Main {
public static void main(String[] args) {
System.out.println("Program
Menampilkan Pola");
System.out.println("_______________________________");
int n;
int i;
int j;
Scanner scan = new Scanner (System.in);
System.out.print ("Banyak Pola =
");
n = scan.nextInt();
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
H A S I L :
0 komentar:
Post a Comment