Struktur modelnya hampir sama dengan struktur perulangan....
Source codenya adalah .........
public class StrukturSwitch {
public static void main(String[] args) {
int nilAngka = 4;
char nilHuruf;
switch(nilAngka) {
case 4 :
nilHuruf = 'A';
break;
case 3 :
nilHuruf = 'B';
break;
case 2 :
nilHuruf = 'C';
break;
case 1 :
nilHuruf = 'D';
break;
case 0 :
nilHuruf = 'E';
break;
default :
nilHuruf = 'E';
break;
}
System.out.println("NIlai angka = " + nilAngka);
System.out.println("Nilai huruf = " + nilHuruf);
}
}
All About JAvA Programming
Categories
- 2 (1)
- array (1)
- balok (1)
- binary (1)
- bukan prima (1)
- cari (1)
- demopassword (1)
- else (2)
- fibonanci (1)
- float (1)
- for (1)
- hitung (1)
- if (2)
- import (2)
- int (4)
- io (1)
- james gosling (1)
- java (2)
- java1 (1)
- java2 (1)
- javax (2)
- jcreator (1)
- Joptionpane (6)
- konversi (3)
- lebar (1)
- luas (2)
- null (1)
- oak (1)
- OOP (1)
- p.l.t (1)
- panjang (1)
- parseInt (1)
- password (1)
- piramid (1)
- prima (1)
- public (1)
- rekursif (1)
- return (1)
- search (1)
- searching (1)
- segitiga (1)
- showinputdialog (2)
- sisi (1)
- sun microsystems (1)
- swing (1)
- triangle (1)
- volume (1)
Blog Archive
Link List
About Me
Cari
rss
12.08
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar