Skip to content

Instantly share code, notes, and snippets.

@milikkan
Created January 3, 2021 12:26
Show Gist options
  • Save milikkan/b21072b4ac7a127ffb148f4a05a6fa69 to your computer and use it in GitHub Desktop.
Save milikkan/b21072b4ac7a127ffb148f4a05a6fa69 to your computer and use it in GitHub Desktop.
if-else kullanmadan not hesaplama
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class Notlar {
public static void main(String[] args) {
Map<Integer, String> notHarfleri = new HashMap<>();
notHarfleri.put(90, "AA ile dersi geçtiniz.");
notHarfleri.put(85, "BA ile dersi geçtiniz.");
notHarfleri.put(80, "BB ile dersi geçtiniz.");
notHarfleri.put(75, "CB ile dersi geçtiniz.");
notHarfleri.put(50, "Kosullu geçtiniz.");
notHarfleri.put(0, "Dersi geçemediniz.");
double vizeNotu = 50.0;
double finalNotu = 50.0;
double yilSonuNotu = (vizeNotu * 0.4) + (finalNotu * 0.6);
System.out.printf("Yıl sonu notunuz = %.2f%n", yilSonuNotu);
Optional<Integer> result = notHarfleri.keySet()
.stream()
.sorted(Comparator.reverseOrder())
.filter(not -> not < yilSonuNotu)
.findFirst();
System.out.println(notHarfleri.get(result.get()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment