Semoga Berhasil....!!!
:)
import javax.swing.JOptionPane;
/**
*
* @author ALi Efendy
*/
public class rekursi{
private static long Faktorial (int n){
if ( n == 1 )
return 1;
else
return n * Faktorial (n-1);
/**
*
* @author ALi Efendy
*/
public class rekursi{
private static long Faktorial (int n){
if ( n == 1 )
return 1;
else
return n * Faktorial (n-1);
}
public static void main (String [] args){
int menu = Integer.parseInt(JOptionPane.showInputDialog("Pilih Menu:" + "\n1.Penjumlahan Faktorial" + "\n2.Pengurangan Faktorial" + "\n3.Perkalian Faktorial"));
switch(menu){
case 1 :
int a = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 1"));
System.out.println(a+" factorial adalah"+" "+Faktorial (a));
int b = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 2"));
System.out.println(b+" factorial adalah"+" "+Faktorial (b));
System.out.println("Hasil Penjumlahan kedua factorial adalah"+" "+(Faktorial (a)+Faktorial (b)));
break;
case 2 :
int c = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 1"));
System.out.println(c+" factorial adalah"+" "+Faktorial (c));
int d = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 2"));
System.out.println(d+" factorial adalah"+" "+Faktorial (d));
System.out.println("Hasil Pengurangan kedua factorial adalah"+" "+(Faktorial (c)-Faktorial (d)));
break;
case 3 :
int e = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 1"));
System.out.println(e+" factorial adalah"+" "+Faktorial (e));
int f = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 2"));
System.out.println(f+" factorial adalah"+" "+Faktorial (f));
System.out.println("Hasil Perkalian kedua factorial adalah"+" "+(Faktorial (e)* Faktorial (f)));
break;
} } }
public static void main (String [] args){
int menu = Integer.parseInt(JOptionPane.showInputDialog("Pilih Menu:" + "\n1.Penjumlahan Faktorial" + "\n2.Pengurangan Faktorial" + "\n3.Perkalian Faktorial"));
switch(menu){
case 1 :
int a = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 1"));
System.out.println(a+" factorial adalah"+" "+Faktorial (a));
int b = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 2"));
System.out.println(b+" factorial adalah"+" "+Faktorial (b));
System.out.println("Hasil Penjumlahan kedua factorial adalah"+" "+(Faktorial (a)+Faktorial (b)));
break;
case 2 :
int c = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 1"));
System.out.println(c+" factorial adalah"+" "+Faktorial (c));
int d = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 2"));
System.out.println(d+" factorial adalah"+" "+Faktorial (d));
System.out.println("Hasil Pengurangan kedua factorial adalah"+" "+(Faktorial (c)-Faktorial (d)));
break;
case 3 :
int e = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 1"));
System.out.println(e+" factorial adalah"+" "+Faktorial (e));
int f = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan 2"));
System.out.println(f+" factorial adalah"+" "+Faktorial (f));
System.out.println("Hasil Perkalian kedua factorial adalah"+" "+(Faktorial (e)* Faktorial (f)));
break;
} } }
tlong bwat program yang nilainya dah diketahui apakah programnya sama...(taufikmartin.blogspot.com)
BalasHapus