Source Code:
import java.util.*; import java.io.*; class mod2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); char [] aiueo = {'a','i','u','e','o','A','I','U','E','O'}; int jmlvoc = 0,jmlKon=0; int isvocal =0; char [] vocal = new char [10]; char [] konsonan= new char [10]; char [] kata; System.out.print("Masukan Kalimat : "); kata = in.next().toCharArray(); class kelas1{ public void cek(){ for(int i =0;i <kata.length;i++){ isvocal = 0; for(int j=0;j<aiueo.length;j++){ if(kata[i] == aiueo[j]){ vocal[jmlvoc] = kata[i]; jmlvoc++; isvocal = 1; } } if(isvocal == 0){ konsonan[jmlKon] = kata[i]; jmlKon++; } } } } class kelas2 extends kelas1{ public void cetak() { System.out.print("Vocal : "); for(int i=0;i<jmlvoc;i++){ System.out.print((vocal[i])+ " "); } System.out.println(""); System.out.print("Konsosnan : "); for(int i=0;i<jmlKon;i++){ System.out.print((konsonan[i])+ " "); } System.out.println(""); } } }
Tidak ada komentar:
Posting Komentar