package Latihan;
public class Dendy {
public static void main(String[] args) {
String name = "aryandie";
System.out.println("nama = " + name);
System.out.println("huruf besar semua (ARYANDIE) = "
+ name.toUpperCase());
System.out.println("panjangnya (8) = " + name.length());
System.out.println("lima huruf terdapan (aryan) = "
+ name.substring(0, 5));
System.out.println("3 huruf belakang (die) = " + name.substring(5));
System.out.println("posisi huruf y (2) = " + name.indexOf("y"));
System.out.println("huruf terbalik urutan (eidnayra) = "
+ balikin(name));
System.out.println("semua huruf di posisi ganjil (ayni)= "
+ ganjil(name));
}
private static String ganjil(String name) {
String ganjil = "";
for (int i = 0; i < name.length(); i++) {
}
return ganjil;
}
private static String balikin(String name) {
String balikan = "";
for (int i = 0; i < name.length(); i++) {
String satuHuruf = name.substring(7 - i, 8 - i);
balikan += satuHuruf;
}
return balikan;
}
}
outprint :
nama = aryandie
huruf besar semua (ARYANDIE) = ARYANDIE
panjangnya (8) = 8
lima huruf terdapan (aryan) = aryan
3 huruf belakang (die) = die
posisi huruf y (2) = 2
huruf terbalik urutan (eidnayra) = eidnayra
semua huruf di posisi ganjil (ayni)=
No comments:
Post a Comment