Program
ke -1
import
java.util.Scanner;
public
class latihando
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int c;
double f;
System.out.println("------------------------------");
System.out.println("CELCIUS FAHREINHEIT");
System.out.println("------------------------------");
c= 1;
do
{
f=1.8 * c + 32;
System.out.println("Celcius:"+c+" Fahreinheit:"+f);
c++;
}
while (c<= 10);
System.out.println("------------------------------");
}
}
|
Hasil
:
Program
ke -2
import
java.util.Scanner;
public
class Tugasdo3
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int bil,jum,rata,n,x;
bil=1;
jum=0;
rata=0;
System.out.print("Banyaknya
data = ");
n=masuk.nextInt();
do
{
System.out.print("Data
ke-"+bil+ "= ");
x=masuk.nextInt();
jum +=x;
rata=jum/n;
bil ++;
}
while (bil<= n);
System.out.println("Jumlah =
"+jum);
System.out.println("Rata = "+rata);
}
}
|
Hasil
:
Program
ke -3
import
java.util.Scanner;
public
class Ulangdo4
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int bil,n,min;
System.out.print("Masukkan
Banyaknya data = ");
n=masuk.nextInt();
bil=1;
min=0;
do
{
System.out.println(bil+bil*bil);
min=min-bil;
bil +=2;
}
while (bil<=n);
System.out.println("Minus =
"+min);
}
}
|
Hasil
:
Program
ke -4
import
java.util.Scanner;
public
class UlangdoWhile
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int bil,n;
System.out.print("Masukkan
Banyaknya data =");
n=masuk.nextInt();
bil= 1;
while (bil<= n)
{
System.out.println(bil);
bil +=2;
}
}
}
|
Hasil
:
Program
ke - 5
import
java.util.Scanner;
public
class UlangdoWhile1
{
public static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int bil,n;
System.out.print("Masukkan
Banyaknya data = ");
n=masuk.nextInt();
bil= 1;
do
{
System.out.println(bil);
bil +=2;
}
while (bil<=n);
}
}
|
Hasil :