Tugas Pemprograman Looping
by : Akhmad Fauzan
09.11.1106
TI.A 2009
Looping
soal:
1. Buat program looping dengan Output:
1
2
3
4
5
6
7
8
9
10
syntax program:
class Bilangan1
{
public static void main (String arg[])
{
for (int i=1;i<11;i=i+1)
{
System.out.println(+i);
}
}
}
2. Buat program looping dengan Output:
50
48
46
44
42
40
Syntax program:
class Bilangan2
{
public static void main (String arg[])
{
for (int i=50;i>38;i=i-2)
{
System.out.println(+i);
}
}
}
3. Buat program looping dengan Output:
13
15
17
19
21
23
25
Syntax program:
class Bilangan3
{
public static void main (String arg[])
{
for (int i=13;i<27;i=i+2)
{
System.out.println(+i);
}
}
}
4. Buat program looping dengan Output:
a=4
b=4
a=6
b=8
a=8
b=12
Syntax program:
class Bilangan4
{
public static void main (String arg[])
{
int a=4;
for (int b=4;b<13;b=b+4)
{
System.out.println ("a="+a);
System.out.println ("b="+b);
a=a+2;
}
}
}
5. Buat program looping dengan output:
a=2
b=4
a=5
b=4
a=8
b=4
Syntax program:
class Bilangan5
{
public static void main (String arg[])
{
int b=4;
for (int a=2;a<4;a=a+3)
{
System.out.println("a="+a);
System.out.println("b="+b);
b=b;
}
}
}
6. Buat program looping dengan output:
a=7
b=5
a=3
b=1
Syntax program:
class Bilangan6
{
public static void main (String arg[])
{
int b=5;
for (int a=7;a>2;a=a-4)
{
System.out.println ("a="+a);
System.out.println ("b="+b);
b=b-4;
}
}
}
Tugas Pemograman
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar