forked from OOP-ADF/Task_1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimeNumber.java
More file actions
31 lines (27 loc) · 875 Bytes
/
PrimeNumber.java
File metadata and controls
31 lines (27 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Nama : Afif Darmawan
* NIM : 1301154133
* Kelas: IF 39-07
*/
package tugas1;
import javax.swing.JOptionPane;
public class No1 {
public static void main(String[] args){
int angka =Integer.parseInt(JOptionPane.showInputDialog("Masukkan Bilangan: "));
//System.out.println("Masukkan Angka Yang Anda Inputkan : ");
boolean prima=false;
if(angka>=2){
prima=true;
for(int a=2; a<angka; a++){
if(angka%a==0){
prima=false;
break;
}
}
}
System.out.println((prima==true?angka+ "BILANGAN PRIMA":angka+"BUKAN BILANGAN PRIMA"));
}
}