Anda di halaman 1dari 5

Nama : Inggrit Agustarini NIM : 09018090

Program Menghitung Banyak Huruf Vokal ----> Pascal uses wincrt; var nama :string; i,vok :integer; BEGIN clrscr; vok:=0; write('Banyak Vokal dalam kalimat berikut =');readln(nama); for i:=1 to length(nama) do case nama[i] of 'A','a','U','u','I','i','E','e','O','o':vok:=vok+1; end; writeln('Jumlah Vokalnya :',vok); READLN; END. Program menghitung huruf konsonan dan huruf vokal ----> Delphi unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Button1: TButton; Label2: TLabel; cb_awal: TComboBox; cb_akhir: TComboBox; GroupBox1: TGroupBox; Label3: TLabel; Label4: TLabel; E_vocal: TEdit; E_konsonan: TEdit; Memo1: TMemo; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var

Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var vocal,konsonan,i,j : integer; begin if(cb_awal.ItemIndex >= cb_akhir.ItemIndex)then showmessage('salah menentukan awal dan akhir') else begin Button1.Enabled; vocal := 0; konsonan := 0; i := cb_awal.itemindex; repeat begin if (i=0) or (i=4) or (i=8) or (i=14) or (i=20) then vocal := vocal + 1 else konsonan := konsonan + 1; inc(i); end; until i > cb_akhir.itemindex; E_vocal.Text := inttostr(vocal); E_konsonan.Text := inttostr(konsonan); end; end; procedure TForm1.FormCreate(Sender: TObject); var c : char; begin cb_awal.clear; cb_akhir.clear; for c:='A' to 'Z' do begin cb_awal.Items.Add(c); cb_akhir.Items.Add(c); end; end; end.

Program Menghitung Banyak Huruf Vokal ----> C++ #include <cstdlib> #include <iostream> #include<string>

using namespace std; int jumlahVokal(char []); int main() { char kata[]="universitas ahmad dahlan"; cout << "Jumlah Huruf Vokal = " << jumlahVokal(kata) << endl; system("PAUSE"); return 0; } int jumlahVokal(char kata[]){ int jumlah_vokal = 0; for(int i = 0;i<=strlen(kata);i++){ if(kata[i]=='a' || kata[i]=='i' || kata[i]=='u'|| kata[i]=='e' || kata[i]=='o'){ jumlah_vokal = jumlah_vokal + 1; } } return jumlah_vokal; }

#include<iostream.h> void main() { char A[25]; int B[25]; int a,b=0,c=0; cout<<"Masukkan Nama anda :";cin.getline(A,sizeof(A)); for(a=0;a<25;a++) { B[a]=A[a]; if(B[a]!=-52&&B[a]!=0&&B[a]!=32) { if(A[a]=='A'||A[a]=='a'||A[a]=='I'||A[a]=='i'||A[a]=='U'||A[a]=='u'||A[a]=='E'||A[a]=='e'||A[a]=='O'||A[a]=='o') { b=b+1; } else { c=c+1; } } } cout<<"Jumlah Huruf Vokal :"<<b<<endl; cout<<"Jumlah Huruf Konsonan :"<<c<<endl; }

Program menghitung huruf vokal ---> VB Dim strenter As String

Dim intcount As Integer Dim i As Integer strenter = LCase (txtEnter. Text) intcount = 0 For i = 1 To strenter If Mid (strenter, i, 1) = "a" Or Mid (strenter, i, 1) = "e" Or Mid (strenter, i, 1) = "i" Or Mid (strenter, i, 1 ) = "o" Or Mid (strenter, i, 1) = "u" Then intcount = intcount + 1 End If Next lblDisplay. Caption = intcount Public Class Form1 Private Sub Button1_Click (ByVal sender Sebagai Obyek Sistem,. ByVal e Sebagai Sistem. EventArgs) Menangani Tombol1. Klik Dim str As String Dim total As Integer total = 0 str = Me. TextBox1. Text 'Mencari vokal masing-masing dan tambahkan menghitung terhadap total total = total + CharCount (str, "A") total = total + CharCount (str, "E") total = total + CharCount (str, "I") total = total + CharCount (str, "O") total = total + CharCount (str, "U") total = total + CharCount (str, "a") total = total + CharCount (str, "e") total = total + CharCount (str, "i") total = total + CharCount (str, "o") total = total + CharCount (str, "u") total = total + CharCount (str, "Y") 'menampilkan hasil MsgBox ("Jumlah Huruf vokal =" & total) End Sub Private Fungsi CharCount (ByVal str As String, ByVal findCH Sebagai Char) As Integer Dim idx, Ln, cnt As Integer Dim ch As String Ln = str. Length cnt = 0 findCH = Char. ToUpper (findCH) 'pastikan char adalah sebuah huruf besar For idx = 0 To Ln - 1 'Membaca surat-surat pribadi dari string dan dikonversi ke huruf besar ch = CChar (str. Substring (idx, 1) ToUpper.) 'dikonversi ke char Jika findCH = ch Kemudian cnt = cnt + 1 'menemukan menghitung selisih pertandingan End If Next Return cnt

End Function End Class Program menghitung huruf ---> Java

import java.util.Scanner;

class Menghitung_banyak_huruf { public static void main(String args[]) { String kata; Scanner input = new Scanner(System.in); System.out.print("Masukkan kata : "); kata = input.nextLine(); System.out.println(); System.out.println("Banyak huruf dari kata yang anda inputkan adalah : " + kata.length()); } }
Program menghitung huruf vocal ---> Java

public class hitungvokal { public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); in.nextLine(); for(int t=0;t<T;t++){ String kalimat; kalimat = in.nextLine(); int jml = 0; for(int i=0;i<kalimat.length();i++){ if(kalimat.substring(i,i+1).equals("a") || kalimat.substring(i,i+1).equals("i") || kalimat.substring(i,i+1).equals("u") || kalimat.substring(i,i+1).equals("e") || kalimat.substring(i,i+1).equals("o") ){ jml++; } } System.out.println(jml); } } }

Anda mungkin juga menyukai