/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author princeiva
*/
public class agriva {
public static void main(String[] args) {
int n=5;
if (n > 2){
for (int i=0; i < n; i++){
for (int j=0; j < n; j++) {
if ((i==0) || (i==n-1) || (j==0) || (j==n-1)) {
System.out.print("*");
}
else {
if (n%2==1){
if ((i==n/2) && (j==n/2)){
System.out.print(" ");
} else {
System.out.print(" ");
}
}
else {
System.out.print(" ");
}
}
}
System.out.println();
}
}
else {
System.out.println("Tidak ada bangun yang akan dibentuk");
}
}
}
public class kimbum {
public static void main (String[]args){
int i,j;
for(i=1;i<=10;i++){
System.out.println(" ");
for(j=1;j<=10;j++){
if(i==j){
System.out.print(" ");
System.out.print("*");
}
else{
System.out.print(" ");
}
}
}
}
}
import javax.swing.JOptionPane;
public class princeiva {
public static void main(String[] args) {
String a= JOptionPane.showInputDialog("banyak bilangan:");
int i = Integer.parseInt(a);
int jmlLoop = 1;
int init=2;
String hasil="";
while (jmlLoop<=i)
{
int jmlFaktor = 0;
int j = 1;
while (j<=init)
{
if ((init%j)==0)
jmlFaktor+=1;
j++;
}
if (jmlFaktor==2)
{
hasil+=init+",";
jmlLoop+=1;
}
init+=1;
}
System.out.println(hasil);
}
}
public class uts1 {
public static void main(String[]args){
int i,j,k,l,m;
for(i=1;i<=100;i++){
j=i%2;
k=i%3;
l=i%5;
m=i;
if(i<=3){
System.out.println("bilangan prima : "+i);
}
else if(i==5){
System.out.println("bilangan prima : "+i);
}
else if(j==0){
m=1;
}
else if(k==0){
m=1;
}
else if(i/m==1){
System.out.println("bilangan prima : "+i);
}
}
}
}
Tidak ada komentar:
Posting Komentar