-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Karar yapılar(if,switch), döngüler, diziler
- Loading branch information
Showing
12 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Ders3/out/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
public class ArrayDizi { | ||
|
||
public ArrayDizi() { | ||
String[] gunler = {"Pzts", "Salı", "Çrşmb", "Prşmb", "Cuma"}; | ||
for (String gun : gunler) { | ||
System.out.println(gun); | ||
} | ||
|
||
String aylar[] = new String[3]; | ||
for (String ay : aylar) { | ||
System.out.println(ay); | ||
} | ||
// String aylar[]; | ||
// aylar = new String[3]; | ||
aylar[0] = "Ocak"; | ||
aylar[1] = "Şubat"; | ||
aylar[2] = "Mart"; | ||
|
||
for (String ay : aylar) { | ||
System.out.println(ay); | ||
} | ||
|
||
// String[] cinsiyet, yas, sinif; // hepsi String dizisidir | ||
String cinsiyet[], yas, sinif; // cinsiyet dizi, yas ve sinif String | ||
|
||
System.out.println("----"); | ||
String[] arabalar = {"Volvo", "BMW", "Ford", "Mazda"}; | ||
for (int i = 0; i < arabalar.length; i++) { // i <= arabalar.length olursa java.lang.ArrayIndexOutOfBoundsException: 4 | ||
System.out.println(arabalar[i]); | ||
} | ||
|
||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
new ArrayDizi(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
public class ForDongusu { | ||
|
||
public ForDongusu() { | ||
|
||
for (int i = 0; i < 5; i++) { | ||
System.out.println(i); | ||
} | ||
|
||
for (int i = 0; i <= 10; i = i + 2) { | ||
System.out.println(i); | ||
} | ||
|
||
// Dış Döngü | ||
for (int i = 1; i <= 2; i++) { | ||
System.out.println("DIŞ - i:" + i); // Executes 2 times | ||
|
||
// İç Döngü | ||
for (int j = 1; j <= 3 && i < 3; j++) { | ||
System.out.println(" İÇ - j:" + j); // Executes 6 times (2 * 3) | ||
} | ||
} | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
new ForDongusu(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
public class IfSinifi { | ||
|
||
public IfSinifi() { | ||
int x = 20; | ||
int y = 18; | ||
|
||
if (x > y) | ||
System.out.println("x y'den büyük"); | ||
|
||
System.out.println("Evet çok haklıymışım"); | ||
|
||
if (x > y) { | ||
System.out.println("x y'den büyük"); | ||
System.out.println("Evet çok haklıymışım"); | ||
} | ||
|
||
int saat = 20; | ||
if (saat < 6) { | ||
System.out.println("İyi geceler. Saat şu anda : " + saat); | ||
} else if (saat < 12) { | ||
System.out.println("Günaydın. Saat şu anda : " + saat); | ||
} else if (saat < 18) { | ||
System.out.println("İyi günler. Saat şu anda : " + saat); | ||
} else { | ||
System.out.println("İyi akşamlar. Saat şu anda : " + saat); | ||
} | ||
|
||
int yasim = 18; | ||
int oyKullanmaYasi = 18; | ||
String oyKullanmaDurumu = (yasim >= oyKullanmaYasi) ? "EVET" : "HAYIR"; | ||
System.out.println("Yaşım " + yasim + ". Oy kullanabilir miyim? " + oyKullanmaDurumu); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
if (i == 4) { | ||
break; | ||
} | ||
System.out.println(i); | ||
} | ||
System.out.println("----"); | ||
for (int i = 0; i < 10; i++) { | ||
if (i == 4) { | ||
continue; | ||
} | ||
System.out.println(i); | ||
} | ||
|
||
} | ||
|
||
public static void main(String[] args) { | ||
new IfSinifi(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
public class Main { | ||
|
||
public Main () { | ||
int x = 10; | ||
int y = 25; | ||
System.out.println("İki sayıdan büyük olanı : " + Math.max(x, y)); | ||
System.out.println("x y'den büyük mü : " + booleanEvetHayirOlarakDon(x > y)); | ||
|
||
System.out.println("x in değeri 10 mu ? " + booleanEvetHayirOlarakDon(x == 10)); | ||
|
||
int myAge = 17; | ||
int votingAge = 18; | ||
System.out.println("Yaşım " + myAge + ". Oy kullanabilir miyim? " + booleanEvetHayirOlarakDon(myAge >= votingAge)); | ||
|
||
int karekok = 50; | ||
System.out.println("Sayının karekökü : " + (int)Math.sqrt(karekok)); | ||
|
||
boolean medipolEglenceliMi = false; | ||
System.out.println("Medipol Eglenceli Mi : " + medipolEglenceliMi); | ||
System.out.println("Medipol Eglenceli Mi : " + (medipolEglenceliMi ? "EVET" : "HAYIR")); | ||
System.out.println("Medipol Eglenceli Mi : " + booleanEvetHayirOlarakDon(medipolEglenceliMi)); | ||
} | ||
|
||
/* | ||
Kısa Hali : (medipolEglenceliMi ? "EVET" : "HAYIR") | ||
*/ | ||
public String booleanEvetHayirOlarakDon(boolean evetHayir) { | ||
if (evetHayir) { | ||
return "EVET"; | ||
} else { | ||
return "HAYIR"; | ||
} | ||
} | ||
|
||
|
||
public static void main(String[] args) { | ||
new Main(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
public class SwitchKullanimi { | ||
|
||
public SwitchKullanimi() { | ||
int gun = 9; | ||
switch (gun) { | ||
case 1: | ||
System.out.println("Pazartesi"); | ||
break; | ||
case 2: | ||
System.out.println("Salı"); | ||
break; | ||
case 3: | ||
System.out.println("Çarşamba"); | ||
break; | ||
case 4: | ||
System.out.println("Perşembe"); | ||
break; | ||
case 5: | ||
System.out.println("Cuma"); | ||
break; | ||
case 6: | ||
System.out.println("Cumartesi"); | ||
break; | ||
case 7: | ||
System.out.println("Pazar"); | ||
break; | ||
default: | ||
System.out.println("Gün numararasını kontrol edin!"); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
new SwitchKullanimi(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
public class WhileDongusu { | ||
|
||
public WhileDongusu() { | ||
int i = 0; | ||
while (i < 5) { | ||
System.out.println("While : " + i); | ||
i++; | ||
} | ||
System.out.println("While Döngüsü bitti. Diğer işlere devam"); | ||
|
||
do { | ||
System.out.println("DoWhile: " + i); | ||
i++; | ||
} while (i < 10); | ||
System.out.println("DoWhile Döngüsü bitti. Diğer işlere devam"); | ||
|
||
// int j = 0; // sonsuz döngü durumu | ||
// while (j < 5) { | ||
// System.out.println("While(2) : " + j); | ||
// } | ||
} | ||
|
||
public static void main(String[] args) { | ||
new WhileDongusu(); | ||
} | ||
} |