Membuat Program Faktorial Di JAVA

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package faktorial;
import javax.swing.*;

/**
*
* @author Angga
*/
public class faktorial {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String faktorial = “”;
System.out.println(“Menghitung Faktorial”);
System.out.println(“——————–“);
do {
faktorial = JOptionPane.showInputDialog(“Faktorial dari : “);
int f=Integer.parseInt(faktorial);

int fak=1;
for(int i=1;i<=f;i++)
fak *=i;
System.out.println ("Faktorialnya dari "+f+" = "+fak);
}
while (true);
}
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s