Tugas Looping
Tugas Looping
PEMOGRAMAN WEB
1.PIRAMIDA
import java.util.Scanner;
int rows = 5;
int i = 1;
while (j > i) {
System.out.print(" ");
j--;
}
int k = 1;
while (k <= i) {
System.out.print("* ");
k++;
}
System.out.println(); i++;
}
3. PIRAMIDA
int rows = 5;
int i = rows;
while (i >= 1) {
int j = 1;
while (j <= i) {
System.out.print("* ");
j++;
}
System.out.println();
i--;
}
}
}
4. PIRAMIDA
public class loop5 {
public static void main(String[] args) {
int rows = 5;
int i = 1;
int j = 1;
while (j <= (rows - i + 1)) {
System.out.print("* ");
j++;
}
System.out.println();
i++;
}
}
5.PIRAMIDA
public class loop2 {
public static void main(String[] args) {
int rows = 5;