Skip to content

Instantly share code, notes, and snippets.

@ahmedselim2017
Last active March 12, 2019 19:39
Show Gist options
  • Save ahmedselim2017/0baf6098ad4316248d6df73342da9979 to your computer and use it in GitHub Desktop.
Save ahmedselim2017/0baf6098ad4316248d6df73342da9979 to your computer and use it in GitHub Desktop.
T3 Ödev
import java.util.*;
public class Main{
public static void main(String[] args) {
//TODO: Soru 1
baslik(1);
int gun = 3; //Perşembe
gun += 346 % 7;
switch(gun){
case 0:
System.out.println("Pazartesi");
break;
case 1:
System.out.println("Salı");
break;
case 2:
System.out.println("Çarşamba");
break;
case 3:
System.out.println("Perşembe");
break;
case 4:
System.out.println("Cuma");
break;
case 5:
System.out.println("Cumartesi");
break;
case 6:
System.out.println("Pazar");
break;
default:
System.out.println("LOL");
}
//TODO: Soru 2
baslik(2);
int toplam = 0;
int sayac = 0;
for(int i = 0; i < 1000; i++){
if(i % 15 == 0){
toplam += i;
sayac ++;
}
}
System.out.println(toplam / sayac);
//TODO: Soru 3
baslik(3);
for(int i = 0; i < 5; i++){
for(int j = 0; j < 5; j++){
System.out.print("*");
}
System.out.println("");
}
//TODO: Soru 4
baslik(4);
int kucuk = -1;
int orta = 0;
int buyuk = 1;
if(kucuk < orta && kucuk < buyuk)
System.out.println(kucuk + "en küçük");
else if(orta < kucuk && orta < buyuk)
System.out.println(orta + "en küçük");
else if(buyuk < kucuk && buyuk < orta)
System.out.println(buyuk + "en küçük");
//TODO: Soru 5
baslik(5);
int saniye = 10000;
System.out.println(saniye + " saniye = " + saniye / 60 + " dakika = " + saniye / 3600 + " saat");
//TODO: Soru 6
baslik(6);
double oran = 0.011;
double azalmaMiktari = 0.0002;
double nufus = 7.235;
for(int i = 2016; i <= 2050; i++){
nufus += nufus * oran;
oran -= azalmaMiktari;
}
System.out.println(nufus);
//TODO: Soru 7
baslik(7);
for(int i = 1; i < 6; i++){
System.out.println(karakterAt(i, "*"));
}
//TODO: Soru 8
baslik(8);
System.out.println(faktoryel(5));
//TODO: Soru 9
baslik(9);
System.out.println("Sonsuz döngüye girip geriye doğru sayar");
//TODO: Soru 10
baslik(10);
int sinir = 5;
for(int i = 1; i < sinir + 1; i++){
if (i != sinir)
System.out.println(karakterAt(i, "*") + karakterAt((sinir * 2 - 1) - i*2," ") + karakterAt(i, "*"));
else
System.out.println(karakterAt(sinir * 2 - 1, "*"));
}
}
public static String karakterAt(int a, String b){
String sonuc = "";
for(int i = 0; i < a; i++){
sonuc += b;
}
return sonuc;
}
public static int faktoryel(int a){
if(a == 0)
return 1;
else
return (a * faktoryel(a - 1));
}
public static void baslik(int a){
System.out.println("-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_");
System.out.println("Soru " + a);
System.out.println("_-_-_-_-_-");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment