import javax.swing.JOptionPane;
class namahari2
{
public static void main(String[] args) throws Exception
{
String bil;
int nourut;
//DataInputStream dis = new DataInputStream (System.in);
bil=JOptionPane.showInputDialog("Masukkan Nomor Urut (0 s/d 6) :");
nourut=Integer.parseInt(bil);
switch (nourut)
{
case 0 :JOptionPane.showMessageDialog(null,"Hari Senin"); break;
case 1 :JOptionPane.showMessageDialog(null,"Hari Selasa"); break;
case 2 :JOptionPane.showMessageDialog(null,"Hari Rabu"); break;
case 3 :JOptionPane.showMessageDialog(null,"Hari Kamis"); break;
case 4 :JOptionPane.showMessageDialog(null,"Hari Jumat"); break;
case 5 :JOptionPane.showMessageDialog(null,"Hari Sabtu"); break;
case 6 :JOptionPane.showMessageDialog(null,"Hari Minggu"); break;
default : JOptionPane.showMessageDialog(null,"Salah Memasukan Nomor Urut !!!");
}
System.exit(0);
}
}
Jumat, 24 Juli 2009
menghitung sisi miring
import javax.swing.JOptionPane;
class menghitung_sisimiring
{
public static void main(String[] args)throws Exception
{
String alas,tinggi;
int a,t;
double akar,kuadratA,kuadratT,jmlAT,sm;
alas=JOptionPane.showInputDialog("Alas :");
a=Integer.parseInt(alas);
tinggi=JOptionPane.showInputDialog("Tinggi :");
t=Integer.parseInt(tinggi);
kuadratA=Math.pow(a,2);
kuadratT=Math.pow(t,2);
jmlAT=kuadratA+kuadratT;
sm=Math.sqrt(jmlAT);
JOptionPane.showMessageDialog(null,"Sisi Miring ="+sm);
System.exit(0);
}
}
class menghitung_sisimiring
{
public static void main(String[] args)throws Exception
{
String alas,tinggi;
int a,t;
double akar,kuadratA,kuadratT,jmlAT,sm;
alas=JOptionPane.showInputDialog("Alas :");
a=Integer.parseInt(alas);
tinggi=JOptionPane.showInputDialog("Tinggi :");
t=Integer.parseInt(tinggi);
kuadratA=Math.pow(a,2);
kuadratT=Math.pow(t,2);
jmlAT=kuadratA+kuadratT;
sm=Math.sqrt(jmlAT);
JOptionPane.showMessageDialog(null,"Sisi Miring ="+sm);
System.exit(0);
}
}
menentukan umur
import java.io.*;
class menentukan_umur_anak
{
public static void main(String[] args) throws Exception
{
DataInputStream dis = new DataInputStream (System.in);
int u;
String umur;
System.out.print("MASUKKAN UMUR ANDA:");
umur=dis.readLine();
u=Integer.parseInt(umur);
if ((u>=1)&&(u<=4))
{
System.out.println("Balita");
}
else
if ((u>=5)&&(u<=14))
{
System.out.println("Anak - Anak");
}
else
if ((u>=15)&&(u<=20))
{
System.out.println("Remaja");
}
else
if ((u>=21)&&(u<=39))
{
System.out.println("Dewasa");
}
else
if ((u>=40)&&(u<=60))
{
System.out.println("Tua");
}
else
if (u>=61)
{
System.out.println("Lansia");
}
}
}
class menentukan_umur_anak
{
public static void main(String[] args) throws Exception
{
DataInputStream dis = new DataInputStream (System.in);
int u;
String umur;
System.out.print("MASUKKAN UMUR ANDA:");
umur=dis.readLine();
u=Integer.parseInt(umur);
if ((u>=1)&&(u<=4))
{
System.out.println("Balita");
}
else
if ((u>=5)&&(u<=14))
{
System.out.println("Anak - Anak");
}
else
if ((u>=15)&&(u<=20))
{
System.out.println("Remaja");
}
else
if ((u>=21)&&(u<=39))
{
System.out.println("Dewasa");
}
else
if ((u>=40)&&(u<=60))
{
System.out.println("Tua");
}
else
if (u>=61)
{
System.out.println("Lansia");
}
}
}
menentukan umur( GUI)
import javax.swing.JOptionPane;
class menentukan_umur_anak2
{
public static void main(String[] args) throws Exception
{
int u;
String umur;
umur=JOptionPane.showInputDialog("Umur :");
u=Integer.parseInt(umur);
if ((u>=0)&&(u<=4))
{
JOptionPane.showMessageDialog(null,"Balita");
}
else
if ((u>=5)&&(u<=13))
{
JOptionPane.showMessageDialog(null,"Anak - Anak");
}
else
if ((u>=14)&&(u<=19))
{
JOptionPane.showMessageDialog(null,"Remaja");
}
else
if ((u>=20)&&(u<=35))
{
JOptionPane.showMessageDialog(null,"Dewasa");
}
else
if ((u>=36)&&(u<=60))
{
JOptionPane.showMessageDialog(null,"Tua");
}
else
if (u>=61)
{
JOptionPane.showMessageDialog(null,"Lansia");
}
System.exit(0);
}
}
class menentukan_umur_anak2
{
public static void main(String[] args) throws Exception
{
int u;
String umur;
umur=JOptionPane.showInputDialog("Umur :");
u=Integer.parseInt(umur);
if ((u>=0)&&(u<=4))
{
JOptionPane.showMessageDialog(null,"Balita");
}
else
if ((u>=5)&&(u<=13))
{
JOptionPane.showMessageDialog(null,"Anak - Anak");
}
else
if ((u>=14)&&(u<=19))
{
JOptionPane.showMessageDialog(null,"Remaja");
}
else
if ((u>=20)&&(u<=35))
{
JOptionPane.showMessageDialog(null,"Dewasa");
}
else
if ((u>=36)&&(u<=60))
{
JOptionPane.showMessageDialog(null,"Tua");
}
else
if (u>=61)
{
JOptionPane.showMessageDialog(null,"Lansia");
}
System.exit(0);
}
}
menentukan golongan
import javax.swing.JOptionPane;
class menentukan_golongan
{
public static void main(String[] args) throws Exception
{
int a,b;
double c,d,e,f,g,h,i,j;
a=1000000;
b=1500000;
c=2000000;
d=1.67*a;
e=1.67*b;
f=1.67*c;
g=a*2;
h=b*2;
i=c*2;
j=0.1*c;
JOptionPane.showMessageDialog(null,"GOLONGAN ANDA"+"\n Gaji Golongan IA :"+a+
"\n Gaji Golongan IIA :"+b+"\n Gaji Golongan IIIA :"+c+"\n Gaji Golongan IB :"+d+
"\n Gaji Golongan IIB :"+e+"\n gaji Golongan IIIB :"+f+"\n Gaji Golongan IC :"+g+
"\n Gaji Golongan IIC :"+h+"\n Gaji Golongan IIIC :"+i+"\n Gaji Golongan IIIA mendapat tunjangan 10% :"+j);
}
}
class menentukan_golongan
{
public static void main(String[] args) throws Exception
{
int a,b;
double c,d,e,f,g,h,i,j;
a=1000000;
b=1500000;
c=2000000;
d=1.67*a;
e=1.67*b;
f=1.67*c;
g=a*2;
h=b*2;
i=c*2;
j=0.1*c;
JOptionPane.showMessageDialog(null,"GOLONGAN ANDA"+"\n Gaji Golongan IA :"+a+
"\n Gaji Golongan IIA :"+b+"\n Gaji Golongan IIIA :"+c+"\n Gaji Golongan IB :"+d+
"\n Gaji Golongan IIB :"+e+"\n gaji Golongan IIIB :"+f+"\n Gaji Golongan IC :"+g+
"\n Gaji Golongan IIC :"+h+"\n Gaji Golongan IIIC :"+i+"\n Gaji Golongan IIIA mendapat tunjangan 10% :"+j);
}
}
memasukan data array
import java.io.*;
class memasukan_data_array
{
public static void main(String[] args)
{
DataInputStream dis=new DataInputStream(System.in);
try
{
int [ ] angka = new int[5];
System.out.println("Ketikan 5 buah angka : ");
System.out.println("==================== ");
for (int i=0;i {
System.out.println("Data ke-"+(i+1)+":");
angka [i] =Integer.parseInt (dis.readLine());
}
System.out.println();
System.out.println("Data yang di cari :");
System.out.println("=================");
int cari =Integer.parseInt(dis.readLine());
int ada = 0;
for (int i=0;(i {
if (angka[1]==cari)
{
ada++;
}
if (ada==0)
{
System.out.println("\nData yang dicari ada ");
ada++;
}
else
if (ada!=0)
{
System.out.println("\nData yang dicari tidak ada ");
ada++;
}
}
}
catch (Exception e)
{
System.out.println("Salah Input Data ! ! ! ! ");
}
}
}
class memasukan_data_array
{
public static void main(String[] args)
{
DataInputStream dis=new DataInputStream(System.in);
try
{
int [ ] angka = new int[5];
System.out.println("Ketikan 5 buah angka : ");
System.out.println("==================== ");
for (int i=0;i
System.out.println("Data ke-"+(i+1)+":");
angka [i] =Integer.parseInt (dis.readLine());
}
System.out.println();
System.out.println("Data yang di cari :");
System.out.println("=================");
int cari =Integer.parseInt(dis.readLine());
int ada = 0;
for (int i=0;(i
if (angka[1]==cari)
{
ada++;
}
if (ada==0)
{
System.out.println("\nData yang dicari ada ");
ada++;
}
else
if (ada!=0)
{
System.out.println("\nData yang dicari tidak ada ");
ada++;
}
}
}
catch (Exception e)
{
System.out.println("Salah Input Data ! ! ! ! ");
}
}
}
matrik
import java.io.*;
class matrik
{
public static void main(String[] args) throws Exception
{
DataInputStream dis = new DataInputStream (System.in);
System.out.println( );
System.out.println( "Masukan Jumlah Baris : " );
int baris = Integer.parseInt (dis.readLine());
System.out.println( "Masukan Jumlah Baris : " );
int kolom = Integer.parseInt (dis.readLine());
int [ ] [ ] matrikA = new int [ baris ] [ kolom ] ;
int [ ] [ ] matrikB = new int [ baris ] [ kolom ] ;
int [ ] [ ] matrikC = new int [ baris ] [ kolom ] ;
System.out.println( );
System.out.println( "Masukan Data Matrik A : " );
System.out.println( "--------------------------------------" );
for (int i=0;i {
for (int j=0;j {
System.out.print( "Data Ke ["+(i+1)+"]"+"["+(j+1)+"]"+""+":"+"" );
matrikA [ i ] [ j ] =Integer.parseInt (dis.readLine());
}
}
System.out.println( );
System.out.println( "Masukan Data Matrik B : " );
System.out.println( "--------------------------------------" );
for (int i=0;i {
for (int j=0;j {
System.out.print( "Data Ke ["+(i+1)+"]"+"["+(j+1)+"]"+""+":"+"" );
matrikB [ i ] [ j ] =Integer.parseInt (dis.readLine());
}
}
System.out.println( );
System.out.println( "Masukan Data Matrik A : " );
System.out.println( "--------------------------------------" );
for (int i=0;i {
for (int j=0;j {
System.out.print (matrikA[ i ] [ j ] + " ");
}
System.out.println();
}
System.out.println( );
System.out.println( "Masukan Data Matrik B : " );
System.out.println( "--------------------------------------" );
for (int i=0;i {
for (int j=0;j {
System.out.print (matrikB[ i ] [ j ] + " ");
}
System.out.println();
}
for (int i=0;i {
for (int j=0;j {
matrikC[ i ] [ j ] =matrikA [ i ] [ j ] +matrikB [ i ] [ j ] ;
}
}
System.out.println();
System.out.println("Hasil Penjumlahan Matrik A + Matrik B : ");
System.out.println("-------------------------------------------------------------");
for (int i=0;i {
for (int j=0;j {
System.out.println(matrikC[ i ] [ j ] + " ");
}
System.out.println();
}
}
}
class matrik
{
public static void main(String[] args) throws Exception
{
DataInputStream dis = new DataInputStream (System.in);
System.out.println( );
System.out.println( "Masukan Jumlah Baris : " );
int baris = Integer.parseInt (dis.readLine());
System.out.println( "Masukan Jumlah Baris : " );
int kolom = Integer.parseInt (dis.readLine());
int [ ] [ ] matrikA = new int [ baris ] [ kolom ] ;
int [ ] [ ] matrikB = new int [ baris ] [ kolom ] ;
int [ ] [ ] matrikC = new int [ baris ] [ kolom ] ;
System.out.println( );
System.out.println( "Masukan Data Matrik A : " );
System.out.println( "--------------------------------------" );
for (int i=0;i
for (int j=0;j
System.out.print( "Data Ke ["+(i+1)+"]"+"["+(j+1)+"]"+""+":"+"" );
matrikA [ i ] [ j ] =Integer.parseInt (dis.readLine());
}
}
System.out.println( );
System.out.println( "Masukan Data Matrik B : " );
System.out.println( "--------------------------------------" );
for (int i=0;i
for (int j=0;j
System.out.print( "Data Ke ["+(i+1)+"]"+"["+(j+1)+"]"+""+":"+"" );
matrikB [ i ] [ j ] =Integer.parseInt (dis.readLine());
}
}
System.out.println( );
System.out.println( "Masukan Data Matrik A : " );
System.out.println( "--------------------------------------" );
for (int i=0;i
for (int j=0;j
System.out.print (matrikA[ i ] [ j ] + " ");
}
System.out.println();
}
System.out.println( );
System.out.println( "Masukan Data Matrik B : " );
System.out.println( "--------------------------------------" );
for (int i=0;i
for (int j=0;j
System.out.print (matrikB[ i ] [ j ] + " ");
}
System.out.println();
}
for (int i=0;i
for (int j=0;j
matrikC[ i ] [ j ] =matrikA [ i ] [ j ] +matrikB [ i ] [ j ] ;
}
}
System.out.println();
System.out.println("Hasil Penjumlahan Matrik A + Matrik B : ");
System.out.println("-------------------------------------------------------------");
for (int i=0;i
for (int j=0;j
System.out.println(matrikC[ i ] [ j ] + " ");
}
System.out.println();
}
}
}
rumus mencari permukaan tabung
import javax.swing.JOptionPane;
class luas_tabung
{
public static void main(String[] args) throws Exception
{
String jari,tinggi;
int r,t;
double ;
jari=JOptionPane.showInputDialog("Jari-jari :");
r=Integer.parseInt(alas);
tinggi=JOptionPane.showInputDialog("Tinggi :");
t=Integer.parseInt(tinggi);
Ltabung=2*r*t
System.out.println("Luas Permukaan Tabung (pecahan): ");
System.out.println("Luas Permukaan Tabung (bulat): ");
}
}
class luas_tabung
{
public static void main(String[] args) throws Exception
{
String jari,tinggi;
int r,t;
double ;
jari=JOptionPane.showInputDialog("Jari-jari :");
r=Integer.parseInt(alas);
tinggi=JOptionPane.showInputDialog("Tinggi :");
t=Integer.parseInt(tinggi);
Ltabung=2*r*t
System.out.println("Luas Permukaan Tabung (pecahan): ");
System.out.println("Luas Permukaan Tabung (bulat): ");
}
}
biodata
import javax.swing.JOptionPane;
class latihan
{
public static void main(String[]args) throws Exception
{
String bil,bal;
bil=JOptionPane.showInputDialog("Masukkan Nama :");
bal=JOptionPane.showInputDialog("Masukkan Alamat :");
JOptionPane.showMessageDialog(null,"Nama Anda :"+bil+"Alamat Anda :"+bal);
System.exit(0);
}
}
class latihan
{
public static void main(String[]args) throws Exception
{
String bil,bal;
bil=JOptionPane.showInputDialog("Masukkan Nama :");
bal=JOptionPane.showInputDialog("Masukkan Alamat :");
JOptionPane.showMessageDialog(null,"Nama Anda :"+bil+"Alamat Anda :"+bal);
System.exit(0);
}
}
Langganan:
Postingan (Atom)