Program
ke -1
import
java.util.Scanner;
public
class Jumlah
{
public
static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
int A, B, jumlah;
System.out.print("Bilangan
Pertama
=
");
A=masuk.nextInt();
System.out.print("Bilangan
Kedua
=
");
B=masuk.nextInt();
jumlah=A+B;
System.out.println(" ");
System.out.println("Jumlah
=
"+jumlah);
}
}
|
Program
ke -2
import
java.util.Scanner;
public
class Konversi
{
public
static void main(String args[])
{
Scanner
masuk = new Scanner (System.in);
float
gram,kg,ton;
System.out.print("Masukan
gram = ");
gram=masuk.nextInt();
kg=gram/1000f;
ton=kg/1000f;
System.out.println("
");
System.out.println(+gram+
"gram= "+kg+ "kilogram");
System.out.println(+kg+
"kg="+ton+ "Ton");
}
}
|
Program
ke -3
import
java.util.Scanner;
public
class Lingkaran
{
public
static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
final float phi=3.14f;
int r;
float keliling, luas;
System.out.print("Jari-jari
lingkaran = ");
r=masuk.nextInt();
keliling = 2*phi*r;
luas = phi*r*r;
System.out.println(" ");
System.out.println("Hasilnya
:");
System.out.println("=============
");
System.out.println("Keliling
lingkaran = "+keliling);
System.out.println("Luas
Lingkaran
=
"+luas);
}
}
|
Program
ke -4
import
java.util.Scanner;
public
class Tugas1
{
public
static void main(String args[])
{
Scanner masuk = new
Scanner(System.in);
float A, B, jumlah, bagi, kali,
minus, mod;
System.out.print("Masukkan
Bil. Pertama = ");
A=masuk.nextFloat();
System.out.print("Masukkan
Bil. Kedua = ");
B=masuk.nextFloat();
jumlah=A+B;
bagi =A/B;
kali =A*B;
minus =A-B;
mod=A%B;
System.out.println(" ");
System.out.println("((( Hasil
Operator
Aritmatika
))) ");
System.out.println("=================================
");
System.out.println(" ");
System.out.println("Jumlah A
+ B =
"+jumlah);
System.out.println("Bagi A
/ B =
"+bagi);
System.out.println("Kali A *
B =
"+kali);
System.out.println("Minus A
- B =
"+minus);
System.out.println("Modulo A
% B =
"+mod);
System.out.println(" ");
}
}
|
Hasil
: