Program
ke -1
import
java.util.Scanner;
public
class TugasDosen
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int bil;
bil=10;
while (bil>= 1)
{
System.out.println(bil*bil);
bil-=2;
}
}
}
|
Hasil
:
Program
ke -2
import
java.util.Scanner;
public
class UlangWhile1
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int bil;
bil=10;
while (bil>= 1)
{
System.out.println(bil);
bil-=2;
}
}
}
|
Hasil
:
Program
ke -3
import
java.util.Scanner;
public
class UlangWhilre2
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int bil,jum;
bil=10;
jum=0;
while (bil>= 1)
{
System.out.println(bil);
jum=jum+bil;
bil-=2;
}
System.out.println("Jumlah =
"+jum);
}
}
|
Hasil
: