Upcoming SlideShare
×

# Looping

709

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
709
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
27
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Looping

1. 1. LOOPING Soal!!! Buatlah Program java untuk menghasilkan output seperti di bawah ini: 1. 1,2,3,4,5,6,7,8,9,10 2. 50,48,46,44,42,40 3. 13,15,17,19,21,23,25 4. a = 4 b=4 a=6 b=8 a=8 b = 12 5. a = 2 b=4 a=5 b=4 a=8 b=4 6. a = 7 b=5 a=3 b=1 7. a = 1 a=3 a=5 b=6 b=8 b = 10 8. Data a = 3 Data b = 10 Data a = 6 Data b = 7 Tugas Praktikum Pemrograman Komputer II Page 1
2. 2. Jawaban: 1. Programnya: class loop1 { public static void main (String arg []) { for(int i=1;i<=10;i=i+1) {System.out.print(" "+i);} {System.out.println(" ");} } } Outputnya: 2. Programnya: class loop2 { public static void main (String arg []) { for(int i=50;i>=40;i=i-2) {System.out.print(" "+i);} {System.out.println(" ");} } } Outputnya: Tugas Praktikum Pemrograman Komputer II Page 2
3. 3. 3. Programnya: class loop3 { public static void main (String arg []) { int a=27; for(int i=13;i<=23;i=i+2) {System.out.print(" "+i);} a=a-2; {System.out.print(" "+a);} {System.out.println(" ");} } } Outputnya: Tugas Praktikum Pemrograman Komputer II Page 3
4. 4. 4. Programnya: class loop4 { public static void main (String arg []) { int a=0; for(int i=4;i<=8;i=i+2) {a=a+4; System.out.println("a= "+i); System.out.println("b= "+a); } } } Outputnya: 5. Programya: class loop5 { public static void main (String arg []) { int a=4; for(int i=2;i<=8;i=i+3) { System.out.println("a= "+i); System.out.println("b= "+a); } } } Outputnya: Tugas Praktikum Pemrograman Komputer II Page 4
5. 5. 6. Programnya: class loop6 { public static void main (String arg []) { int b=9; for(int a=7;a>=3;a=a-4) { b= b-4; System.out.println("a= "+a); System.out.println("b= "+b); } } } Outputnya: Tugas Praktikum Pemrograman Komputer II Page 5
6. 6. 7. Programnya: class loop7 { public static void main (String arg []) { for(int a=1;a<=5;a=a+2) {System.out.println("a= "+a);} for(int b=6;b<=10;b=b+2) { System.out.println("b= "+b);} } } Outputnya: 8. Programnya: class loop8 { public static void main (String arg []) { int b=13; for(int a=3;a<=6;a=a+3) { b= b-3; System.out.println("Data a = "+a); System.out.println("Data b = "+b); } } } Outputnya: Tugas Praktikum Pemrograman Komputer II Page 6
7. 7. #####GOOD LUCK##### Created By: Sutriyono (08.11.0670) TI 08 A Tugas Praktikum Pemrograman Komputer II Page 7