May 31

Şimdi yapıcağımız uygulama güzel bir Applet uygulaması.

Önce rengi belirlenmiş olan renkli bir daire çiziyoruz. Bu rengi for döngüsü içinde olan if şartıyla belirliyoruz. for döngüsü her dönüşünde dairenin rengi ve boyutu değiştiriyoruz. Yani öncelile 300 birim olarak belirlenmiş genişliği her dönüşle 50 azaltıyoruz. Bu tam 5 kez yaptırıyoruz. En son içte kalan boşluğuda kırmız renkte bir daire ile dolduruyoruz. Şekllimiz:

——————Program Başlangıç——————

/*
 * İç içe renkli daireler
 */

/**
 *
 * @yazar MeHMeT CaN
 */

import java.applet.Applet;
import java.awt.*;
public class AtisPoligonu extends Applet
{
    public void paint(Graphics sayfa)
    {
        final int MAKS_GNSLK=300, NY=5, YUZUK_GNSLK=25;
        int x=0, y=0, cap;
       
        setSize(MAKS_GNSLK, MAKS_GNSLK);//Pencere boyutu belirlendi
        setBackground(Color.cyan);//Arkaplan rengi belirlendi.
        cap=MAKS_GNSLK;//Dairenin çapı belirlendi.
        sayfa.setColor(Color.white);//İşlem yapmak için beyaz renk seçildi
       
        for(int syc=0; syc<NY; syc++)
        {
            if(sayfa.getColor()==Color.black)
                sayfa.setColor(Color.white);
            else
                sayfa.setColor(Color.black);
            sayfa.fillOval(x, y, cap, cap);
            cap-=(2*YUZUK_GNSLK);
           
            x+=YUZUK_GNSLK;
            y+=YUZUK_GNSLK;
        }
        sayfa.setColor(Color.red);
        sayfa.fillOval(x, y, cap, cap);
    }
}

——————Program Bitiş————————

 

May 19

Dizileri kullanmadan 10×10 bir matris yapıcağız.
Kullanıcağımız karakterler (0,1,2) olucak.

Yapıcağımız şekil:

0 1 1 1 1 1 1 1 1 1
2 0 1 1 1 1 1 1 1 1
2 2 0 1 1 1 1 1 1 1
2 2 2 0 1 1 1 1 1 1
2 2 2 2 0 1 1 1 1 1
2 2 2 2 2 0 1 1 1 1
2 2 2 2 2 2 0 1 1 1
2 2 2 2 2 2 2 0 1 1
2 2 2 2 2 2 2 2 0 1
2 2 2 2 2 2 2 2 2 0

——————Program Başlangıç——————

/*
* Matris uygulaması
0 1 1 1 1 1 1 1 1 1
2 0 1 1 1 1 1 1 1 1
2 2 0 1 1 1 1 1 1 1
2 2 2 0 1 1 1 1 1 1
2 2 2 2 0 1 1 1 1 1
2 2 2 2 2 0 1 1 1 1
2 2 2 2 2 2 0 1 1 1
2 2 2 2 2 2 2 0 1 1
2 2 2 2 2 2 2 2 0 1
2 2 2 2 2 2 2 2 2 0

*/

/**
*
* @yazar MeHMeT CaN
*/

public class Matris
{
public static void main(String[] args)
{
for(int i=1; i<=10; i++)
{
for(int k=1; k<=10; k++)
if(i==k)
System.out.print(“0 “);
else if (i<k)
System.out.print(“1 “);
else
System.out.print(“2 “);
System.out.println();
}

}

}
——————Program Bitiş————————

May 18

Şimdi yıldız (*) larla işi ilerleteceğiz ve konsolda çalışan içi boş baklava dilimi şekli çizdireceğiz.
İşte şeklimiz:

Bunu gerçekleştiren programımız:

——————Program Başlangıç——————

/*
* İçi boş baklava dilimi.
* http://malacalolu.blogsayfasi.com
*/

/**
*
* @yazar MeHMeT CaN
*/

public class baklava
{
public static void main(String[] args)
{
String bos=“”,bos2=” “,boss;
int x=18;
for(int i=1; i<=10; i++)
{
for(int k=i; k<=10; k++)
System.out.print(“*”);

System.out.print(bos);

bos += ” “;

for(int s=i; s<=10; s++)
System.out.print(“*”);
System.out.println();
}
for(int a=1; a<=10; a++)
{
for(int b=1; b<=a; b++)
System.out.print(“*”);

boss=bos2.substring(0, x);
System.out.print(boss);
x -=2;

for(int c=1; c<=a; c++)
System.out.print(“*”);
System.out.println();
}

}

}

——————Program Bitiş————————

May 18

Şimdi yapıcağımız uygulama for döngüsünü iyi kavramamız için çok iyi bir örnek olucaktır.
Yıldız (*) karakterini kullanarak konsolda dik üçgen çizdireceğiz. üçgenimiz 10×10 olsun.

Öncelikle yapıcağımız şekil şu olsun:

*
**
***
****
*****
******
*******
********
*********
**********

Bunu gerçekleştiren pogram:
——————Program Başlangıç——————

/*
* Dik Üçgen1
* http://malacalolu.blogsayfasi.com
*/

/**
*
* @yazar MeHMeT CaN
*/

public class yildiz1
{
public static void main(String[] args)
{
for(int i=1; i<=10; i++)
{

for(int k =1; k<=i; k++)
System.out.print(“*”);
System.out.println();
}
}
}
——————Program Bitiş————————

Şimdiki şeklimiz ise bu:

Bunu gerçekleştiren pogram:
——————Program Başlangıç——————

/*
* Dik Üçgen2
* http://malacalolu.blogsayfasi.com
*/

/**
*
* @yazar MeHMeT CaN
*/

public class Yildiz2
{
public static void main(String[] args)
{
String bosluk=“”;
for(int i=1; i<=10; i++)
{
System.out.print(bosluk);
bosluk +=” “;
for(int k =i; k<=10; k++)
System.out.print(“*”);
System.out.println();
}
}
}

——————Program Bitiş————————

Diğer şeklimiz:

Bunu gerçekleştiren pogram:
——————Program Başlangıç——————

/*
* Dik Üçgen3
* http://malacalolu.blogsayfasi.com
*/

/**
*
* @yazar MeHMeT CaN
*/

public class Yildiz3
{
public static void main(String[] args)
{
String bsgor,bosluk = ” “;
int s=10;
for(int i = 1; i<=10; i++)
{
–s;
bsgor = bosluk.substring(0, s);
System.out.print(bsgor);

for(int k = 1; k<=i; k++)
System.out.print(“*”);
System.out.println();
}
}
}
——————Program Bitiş————————

Son şeklimiz ise:

***********
**********
*********
********
*******
******
*****
****
***
**
*
Bunu gerçekleştiren pogram:
——————Program Başlangıç——————

/*
* Dik Üçgen4
* http://malacalolu.blogsayfasi.com
*/

/**
*
* @yazar MeHMeT CaN
*/

public class Yildiz4
{
public static void main(String[] args)
{

for(int i=10; i>=0; i–)
{
for(int k=0; k<=i; k++)
System.out.print(“*”);
System.out.println();
}

}
}

——————Program Bitiş————————

iyi çalışmalar :)