* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tugasmaterialgo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JOptionPane;
/**
*
* @author adhysyamsul
*/
public class Faktorial {
public static void main(String[] args) throws IOException {
// double input;
String ad;
ad=JOptionPane.showInputDialog("Masukkan Bilangan Yg akan Di faktorialkan");
// input=Integer.parseInt(ad);
double y=Double.parseDouble(ad);
// BufferedReader rd=new BufferedReader(new InputStreamReader(System.in));
// System.out.println("MAsukkan bilangan yang akan di Faktorialkan :");
// double x=Double.parseDouble(rd.readLine());
double z=1;
for(double i=1; i<=y ;i++){ z= z * i ; // System.out.println(" hasil faktorialnya : " + x + " adalah " + z); } //System.out.println(" hasil faktorialnya : " + y + " adalah " + z); JOptionPane.showMessageDialog(null,"Hasil Faktorialnya = "+"\n"+ y + " adalah " + z); JOptionPane.showMessageDialog(null,"=============================================="+"\n" +" SALAM IPOK JAVA COM"+"\n" +" http://4dhyipokjava.blogspot.com"+"\n" +"=============================================="); } }







No comments:
Post a Comment