Best Rapidshare Search
package percobaan1;
import javax.swing.JOptionPane;
public class Percobaan1{
public static void main(String[]args){
int x;
String a=JOptionPane.showInputDialog(null, "masukkan kalimat Alay: );
a=a.toUpperCase();
for(x=0; x < a.length ( ) ; x + + ){
char g=a.charAt(x);
switch (g){
case ('0'):
System.out.print("O");
break;
case ('1'):
if(a.charAt(x+1)=='2'){
System.out.print("R");
x=x+1;
}
else if(a.charAt(x+1)=='-'){
System.out.print("H");
x=x+2;
}
else if(a.charAt(x+1)=='1'){
if(a.charAt(x+1)=='1'){
System.out.print("M");
x=x+2;
}
}
else{
if(a.charAt(x)=='1'){
System.out.print("I");
}
}
break;
case '3':
System.out.print("E");
break;
case '4':
System.out.print("A");
break;
case '5':
System.out.print("S");
break;
case '6':
System.out.print("G");
break;
case '7':
System.out.print("T");
break;
case '8':
System.out.print("B");
break;
case '9':
System.out.print("G");
break;
default :
System.out.print(g);
break;
}
}
System.out.println();
}
}
Ket: yang berhuruf tebal adalah contoh percabangan dalam percabangan
package percobaan1;
import javax.swing.JOptionPane;
public class Percobaan1{
public static void main(String[]args){
int x;
String a=JOptionPane.showInputDialog(null, "masukkan kalimat Alay: );
a=a.toUpperCase();
for(x=0; x < a.length ( ) ; x + + ){
char g=a.charAt(x);
switch (g){
case ('0'):
System.out.print("O");
break;
case ('1'):
if(a.charAt(x+1)=='2'){
System.out.print("R");
x=x+1;
}
else if(a.charAt(x+1)=='-'){
System.out.print("H");
x=x+2;
}
else if(a.charAt(x+1)=='1'){
if(a.charAt(x+1)=='1'){
System.out.print("M");
x=x+2;
}
}
else{
if(a.charAt(x)=='1'){
System.out.print("I");
}
}
break;
case '3':
System.out.print("E");
break;
case '4':
System.out.print("A");
break;
case '5':
System.out.print("S");
break;
case '6':
System.out.print("G");
break;
case '7':
System.out.print("T");
break;
case '8':
System.out.print("B");
break;
case '9':
System.out.print("G");
break;
default :
System.out.print(g);
break;
}
}
System.out.println();
}
}
Ket: yang berhuruf tebal adalah contoh percabangan dalam percabangan
0 komentar:
Post a Comment