DEFINISI MASALAH SOURCE CODE

DASAR PROGRAM TEKNOLOGI INFORMASI DAN ILMU KOMPUTER UNIVERSITAS BRAWIJAYA BAB : PERULANGAN NAMA : MOH. ARIF ANDRIAN NIM : 156150600111002

A. DEFINISI MASALAH

1. Buatlah program dengan tampilan sebagai berikut :

Masukkan nilai n = 4

2. Buatlah looping yang menuliskan nama anda secara vertikal, dengan huruf yang

sesuai dengan huruf yang di tulisan Contoh menuliskan A : A A A A A A A A A A A A A A

3. Buatlah program sederhana untuk menghitung beberapa volume bidang dengan

tampilan awal sebagai berikut : MENU 1. KELUAR 2. HITUNG VOLUME BALOK 3. HITUNG VOLUME BOLA 4. HITUNG VOLUME KERUCUT 5. HITUNG VOLUME SILINDER 6. HITUNG VOLUME LIMAS SEGITIGA MASUKKAN PILIHAN ANDA :

A. SOURCE CODE

Tugas Praktikum 3.1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 package Praktikum3; import java.util.Scanner; public class Tugas1 { public static void mainString[] args { Scanner in = new ScannerSystem.in; System.out.printMasukkan nilai n : ; int n = in.nextInt; for int baris = 1; baris = n; baris++ { for int spasi = n-1; spasi = baris; spasi-- { System.out.print ; } for int bintang = 1; bintang = baris; bintang++ { System.out.print ; } System.out.println ; } } } Tugas Praktikum 3.2 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 package Praktikum3; public class Tugas2 { public static void mainString[] args { int baris, spasi, huruf; int n = 6; huruf A for baris = 0; baris n; baris++ { for spasi = 0; spasi n - baris; spasi++ { System.out.print ; } for huruf = 0; huruf 2 baris + 1; huruf+ + { if baris == 0 || baris == n - 3 { System.out.printA; } else { if huruf == 0 || huruf == 2 baris { System.out.printA; } else { System.out.print ; } } } System.out.println; } System.out.println; Huruf N for baris = 0; baris n; baris++ { 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 for huruf = 0; huruf n; huruf++ { if huruf == 0 || huruf == baris || huruf == 5 { System.out.print N; } else { System.out.print ; } } System.out.println; } System.out.println; Huruf D for baris = 0; baris n; baris++ { for huruf = 0; huruf n; huruf++ { if huruf == 0 { System.out.print ; } } for huruf = 0; huruf n - 2; huruf++ { if baris == n - 1 || baris == n - 6 { System.out.print D; } } for huruf = 0; huruf n; huruf++ { if huruf == 0 || huruf == 4 { if baris == 0 || baris == 5 { System.out.print ; } else { System.out.print D; } } else { System.out.print ; } } System.out.println; } System.out.println; Huruf R for baris = 0; baris n; baris++ { for huruf = 0; huruf n; huruf++ { if huruf == 0 { System.out.print ; } } for huruf = 0; huruf n - 1; huruf++ { if huruf == 0 || baris == 2 || baris == 0 || baris == huruf + 1 || baris == huruf - 3 { System.out.print R; } else { System.out.print ; } 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10 10 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 11 11 1 11 2 } System.out.println; } System.out.println; Huruf I for baris = 0; baris n; baris++ { for huruf = 0; huruf n; huruf++ { if huruf == 3 { System.out.printI; } else { System.out.print ; } } System.out.println; } System.out.println; huruf A for baris = 0; baris n; baris++ { for spasi = 0; spasi n - baris; spasi++ { System.out.print ; } for huruf = 0; huruf 2 baris + 1; huruf+ + { if baris == 0 || baris == n - 3 { System.out.printA; } else { if huruf == 0 || huruf == 2 baris { System.out.printA; } else { System.out.print ; } } } System.out.println; } System.out.println; Huruf N for baris = 0; baris n; baris++ { for huruf = 0; huruf n; huruf++ { if huruf == 0 || huruf == baris || huruf == 5 { System.out.print N; } else { System.out.print ; } } System.out.println; } } } 11 3 11 4 11 5 11 6 11 7 11 8 11 9 12 12 1 12 3 12 4 Tugas Praktikum 3.3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 package Praktikum3; import java.util.Scanner; public class Tugas3 { public static void mainString[] args { int pilihan; do { System.out.println\nMENU :; System.out.println0. KELUAR; System.out.println1. HITUNG VOLUME BALOK; System.out.println2. HITUNG VOLUME BOLA; System.out.println3. HITUNG VOLUME KERUCUT; System.out.println4. HITUNG VOLUME SILINDER; System.out.println5. HITUNG VOLUME LIMAS SEGITIGA; System.out.print MASUKKAN PILIHAN ANDA : ; Scanner in = new ScannerSystem.in; pilihan = in.nextInt; if pilihan == 0 { System.out.println\nTerima Kasih...; break; } else if pilihan == 1 { System.out.println\nMENGHITUNG VOLUME BALOK ; System.out.printMasukkan panjang : ; int p = in.nextInt; System.out.printMasukkan Lebar : ; 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 int l = in.nextInt; System.out.printMasukkan tinggi : ; int t = in.nextInt; int volume = p l t; System.out.printlnVolume : + volume + cm3; } else if pilihan == 2 { System.out.println\nMENGHITUNG VOLUME BOLA ; double phi = double 3.14; System.out.printMasukkan Radius : ; double r = in.nextDouble; double volume = double 4 3 phi Math.powr, 3; System.out.printlnVolume : + volume + cm3; } else if pilihan == 3 { System.out.println\nMENGHITUNG VOLUME KERUCUT ; double phi = double 3.14; System.out.printMasukkan Radius : ; double r = in.nextDouble; System.out.printMasukkan tinggi : ; double t = in.nextDouble; double volume = double phi Math.powr, 2 t 3; System.out.printlnVolume : + volume + cm3; } else if pilihan == 4 { System.out.println\nMENGHITUNG VOLUME SILINDER ; double phi = double 3.14; System.out.printMasukkan Radius : ; double r = in.nextDouble; System.out.printMasukkan tinggi : ; double t = in.nextDouble; double volume = double phi Math.powr, 2 t; System.out.printlnVolume : + volume + cm3; } else if pilihan == 5 { System.out.println\nMENGHITUNG VOLUME LIMAS SEGITIGA ; System.out.printMasukkan panjang : ; int p = in.nextInt; System.out.printMasukkan Lebar : ; int l = in.nextInt; System.out.printMasukkan tinggi : ; int t = in.nextInt; double volume = double p l 2 t 3; 64 65 66 67 68 69 70 71 System.out.printlnVolume : + volume + cm3; } else{ System.out.println\nInputan Tidak Sesuai...; break; } } while pilihan=0; } }

B. PEMBAHASAN