Program ini merupakan program Faktorial, Permutasi, dan Kombinasi dengan Java. Semoga program ini dapat membantu anda.
import java.io.*;
import javax.swing.*;
public class peluang {
public static void main (String[]args) throws IOException {
BufferedReader input=new BufferedReader (new InputStreamReader(System.in));
do {
System.out.println("PROGRAM PERMUTASI DAN KOMBINASI");
System.out.println("===============================");
System.out.println("1. Faktorial");
System.out.println("2. Permutasi");
System.out.println("3. Kombinasi");
System.out.println("4. Keluar");
System.out.println("===============================");
System.out.print("Masukan pilihan [1..4] = ");
int pi=Integer.parseInt(input.readLine());
switch(pi){
case 1:
System.out.print("Masukan bilangan faktorial = ");
int b=Integer.parseInt(input.readLine());
int c=1;
int d;
for(d=b;d>=1;d--) {
c*=d;
}
System.out.println(b+"! = "+c);
break;
case 2:
System.out.println("Bentuk Umum Permutasi mPn");
System.out.print("Masukan bilangan m = ");
int m=Integer.parseInt(input.readLine());
System.out.print("Masukan bilangan n = ");
int n=Integer.parseInt(input.readLine());
int o=1;
int s=1;
int p, q, r;
for(p=m;p>=1;p--) {
o*=p;
}
q=(m-n);
for(r=q;r>=1;r--) {
s*=r;
}
System.out.println(m+"P"+n+" = "+(o/s));
break;
case 3:
System.out.println("Bentuk Umum Kombinasi xCy");
System.out.print("Masukan bilangan x = ");
int x=Integer.parseInt(input.readLine());
System.out.print("Masukan bilangan y = ");
int y=Integer.parseInt(input.readLine());
int t=1;
int u=1;
int v=1;
int w, z, k, j;
for(w=x;w>=1;w--) {
t*=w;
}
k=(x-y);
for(z=k;z>=1;z--) {
u*=z;
}
for(j=y;j>=1;j--) {
v*=j;
}
System.out.println(x+"C"+y+" = "+(t/(u*v)));
break;
case 4:
break;
default:
System.out.println("Tolong masukan yang benar pilihannya!!");
break;
}
}
while (JOptionPane.showConfirmDialog(null,"Ulang lagi?")==JOptionPane.YES_OPTION);
}
}
Kamis, 14 April 2011
Program Faktorial, Permutasi, dan Kombinasi dengan Java
Kamis, April 14, 2011
3 comments
Langganan:
Posting Komentar (Atom)
asik nih, bisa buat tugas kuliah hehe
BalasHapusmampir sini ya http://gudasi.com
mudah-mudahan bermanfaat :)
makasih sudah mampir. :)
HapusHotels near Casino of Norwich - Mapyro
BalasHapusThe following hotels are in Norwich (Newmarket, Norwich) and 보령 출장마사지 Uncasville (Hilton, 충주 출장마사지 Uncasville) and 강릉 출장샵 have a casino/hotel. If you 김제 출장샵 need to cancel the 남양주 출장안마 hotel reservation