Skip to content

Commit

Permalink
Ders 4(Ders3 Projesi)
Browse files Browse the repository at this point in the history
Karar yapılar(if,switch), döngüler, diziler
  • Loading branch information
srkns committed Mar 30, 2023
1 parent bc42786 commit 69a8ff5
Show file tree
Hide file tree
Showing 12 changed files with 262 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Ders3/out/
8 changes: 8 additions & 0 deletions Ders3/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Ders3/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Ders3/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Ders3/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Ders3/Ders3.iml
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>
39 changes: 39 additions & 0 deletions Ders3/src/ArrayDizi.java
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();
}

}
29 changes: 29 additions & 0 deletions Ders3/src/ForDongusu.java
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();
}

}
53 changes: 53 additions & 0 deletions Ders3/src/IfSinifi.java
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();
}

}
39 changes: 39 additions & 0 deletions Ders3/src/Main.java
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();
}
}
36 changes: 36 additions & 0 deletions Ders3/src/SwitchKullanimi.java
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();
}

}
26 changes: 26 additions & 0 deletions Ders3/src/WhileDongusu.java
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();
}
}

0 comments on commit 69a8ff5

Please sign in to comment.