Menampilkan Deret Fibonaci Menggunakan JCreator (JAVA)

import java.io.*;
public class fiboaci
{
public static void main (String [] args)throws IOException
{
    int x = 1, y = 1, z = 1;
    DataInputStream a = new DataInputStream (System.in);
    System.out.print ("Masukan Angka = ");
    int b = Integer.parseInt (a.readLine());
   
    for (int i = 0; i < b; i++)
    {
       
        System.out.print (z + ", ");
        z = x + y;
        x = y;
        y = z;
    }
    System.out.print (" ");
}
}

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Program Bilangan Prima Menggunakan JCreator (JAVA)

import java.io.*;
public class prima
{
public static void main (String [] args)throws IOException
{
   
    DataInputStream a = new DataInputStream (System.in);
    System.out.print ("Masukan Angka = ");
    int b = Integer.parseInt (a.readLine());
    int z=0;
    for(int i = 2; i<=b/2; i++)
        {
            if(b%i==0)
            {
            z = z + 1;
            }
        }
       
        if (z>0 || b<2)
        {
            System.out.println(b+" = Bukan Prima");
        }
        else
        {
            System.out.println(b+" = Bilangan Prima");
        }
}
}

Hasil output dari program diatas adalah :



Sekian Postingan saya kali ini Semoga bermanfaat...

Terima Kasih...
SALAM TEKNOLOGI.....

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Program Faktorial Sederhana Menggunakan JCreator (JAVA) Dengan 2 Class

import java.io.*;
public class faktorial2
{
public static long factorial (int n)
{
if (n<=1)
return 1;
else
return n * factorial (n-1);
}

public static void main (String [] args)throws IOException
{
DataInputStream a = new DataInputStream (System.in);
System.out.print ("Masukan Angka Faktorial = ");
int b = Integer.parseInt (a.readLine());
int c;
System.out.print ("Faktorial "+b+ "! = ");
for (c=b; c>0; c--)
if (c>1)
{
System.out.print (c+ " * ");
}
else
{
System.out.print (c+ " = ");
}
for (int d=b; d<=b; d++)

System.out.println (factorial (d));

}
}

Output dari program diatas adalah sebagai berikut :



Sekian Posting Saya kali ini.. Semoga Bermanfaat. . . . .! ! !
Terima Kasih...

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Program Faktorial Sederhana Menggunakan JCreator (JAVA)

import java.io.*;
public class faktorial
{
public static void main (String [] args)throws IOException
{
int d=1;
DataInputStream a = new DataInputStream (System.in);
System.out.print ("Masukan Angka Faktorial = ");
int b = Integer.parseInt (a.readLine());
int c;
System.out.print ("Faktorial " +b+ "! = ");
for (c=b; c>0; c--)

if(c>1)
{
d=d*c;
System.out.print (c+ " * ");
}
else
{
System.out.print (c+ " = ");
}

System.out.print (d);
System.out.println();
}
}


Output dari Program di atas adalah sebagai berikut :




Sekian posting saya kali ini.. jika ada yang ingin di tanyakan seputar program diatas silahkan comment di posting ini... Terima Kasih telah membaca posting saya ini.. semoga bermanfaat...

SALAM TEKNO....!!!!

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS