📄 JB_008_switch_case.java .java dosyası

⬇️ İndir
import java.util.Scanner; public class JB_008_switch_case { public static void main (String[] args) { System.out.println(""); /* switch (kontrol) { case x : ........; break; case y : ........; break; case z : ........; break; default : ........; } switch (kontrol) 1) kelime 2) rakam 3) karakter */ Scanner klavye = new Scanner(System.in); /* System.out.print("Bir sehir ismi giriniz : "); String sehir = klavye.next(); switch (sehir) { case "istanbul" : System.out.println(sehir + " plaka kodu : 34"); System.out.println("Telefon kodu (Avrupa) : 212"); System.out.println("Telefon kodu (Anadolu) : 216"); break; case "adiyaman" : System.out.println(sehir + " plaka kodu : 02"); System.out.println("Telefon kodu (Avrupa) : 416"); break; case "elazig" : System.out.println(sehir + " plaka kodu : 23"); System.out.println("Telefon kodu (Avrupa) : 424"); break; default : System.out.println(sehir + " ile ilgili kayit bulunamadi."); } */ /* System.out.print("1-7 arasi bir sayi giriniz : "); int gün = klavye.nextInt(); switch (gün) { case 1 : System.out.println("Pazartesi"); break; case 2 : System.out.println("Sali"); break; case 3 : System.out.println("Çarsamba"); break; case 4 : System.out.println("Persembe"); 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("1-7 den farkli bi giris yapildi."); } */ System.out.println("SORU :"); System.out.println("Lavanta çiçeğinin anlami nedir?\n"); System.out.println("a) Sevgi ve sadakat"); System.out.println("b) Bir teklifi reddetmek ve af dilemek"); System.out.println("c) Hayranlık, zarafet ve şıklık"); System.out.println("d) Bilgelik, saygı ve övgü\n"); System.out.print("Cevabiniz : "); char cevap = klavye.next().trim().charAt(0); // 0 1 2 3 // ankara // zonguldak switch (cevap) { case 'a' : System.out.println("Yanlış"); break; case 'b': System.out.println("Yanlış"); break; case 'c': System.out.println("Doğru"); break; case 'd': System.out.println("Yanlış"); break; default: System.out.println("a-b-c-d 'den farkli giriş oldu!..."); } char unicode_a = '\u249c'; // (a) sembolü... char unicode_b = '\u249d'; // (b) sembolü... char unicode_c = '\u249e'; // (c) sembolü... char unicode_d = '\u249f'; // (d) sembolü... klavye.close(); } }