-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass_Piramida.java
48 lines (40 loc) · 1.23 KB
/
Class_Piramida.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package P1;
import java.io.FileNotFoundException;
import java.util.Formatter;
/**
*
* @author NADIA
*/
public class Class_Piramida {
public static void main(String[] args){
try (Formatter file = new Formatter("C:\\Users\\ASUS\\OneDrive\\Documents\\NetBeansProjects\\P1_PBO\\src\\main\\java\\P1\\Output.txt")) {
int[] nim = {2,1,4,1,7,6,2,0,4,6};
int count=0;
int a=1;
do{
int b=4;
do{
System.out.print(" ");
file.format("%s", " ");
b--;
}
while(b>=a);
int c=1;
do{
System.out.print(nim[count] + " ");
file.format("%s", nim[count] + " ");
count++;
c++;
}
while(c<=a);
a++;
System.out.println();
file.format("%s %n", " ");
}
while(a<=4);
}catch(FileNotFoundException ex){
//Menampilkan pesan jika file tidak ditemukan
System.out.println("File Tidak Ditemukan");
}
}
}