Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Java Online


    
    //Import class
    import java.time.Year;
    import java.util.Scanner;
    public class konsonanvokal{
    public static void main(String []args){
        
    //Paparan output-maklumanawal aturcara
    System.out.println("ATURCARA BILANG HURUF KONSONAN & VOKAL");
        
    //Pengisytiharan pembolehubah Scanner
     Scanner taip =new Scanner(System.in);
      
    //Papar teks pertanyaaan dan istihar pembolehubah
     System.out.println("Taipkan satu perkataandan tekan ENTER");
     String perkataan = taip.next();
     char[] hrurufv = perkataan.toCharArray();
     int vokal = 0;
      
    //Kawalan ulangan for
     for (char h: hurufv) {
         if(h == 'a' || h  == 'A' || h == 'e' || h == 'E'|| h == 'i' || h== 'I'  || h == 'o'|| h == 'O' || h == 'u' || h == 'U') {
    //Penambah
     vokal++;
      }
     }
     
     //Paparan output
     System.out.println("Bilangan huruf vokal dalam " + perkataan + " adalah: " + vokal);
     System.out.println("Bilangan huruf konsonan dalam " + perkataan + " adalah: " + ( hurufv.length - vokal));
     
      }
        
     }

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.