Menghitung Jumlah Karakter di Tiga Bahasa: Indonesia, Inggris dan Sunda

TUGAS KEAMANAN INFORMASI LANJUT
 

Menghitung jumlah karakter paling sering paling sering muncul dalam bahasa:
1. Indonesia
2. Inggris
3. Sunda
Untuk dapat menghitung jumlah karakter dari sebuah artikel dengan masing-masing bahasa tersebut, saya menggunakan program HTML dan JavaScript. Program ini merupakan modifikasi source code yang diberikan oleh salah seorang teman saya yang merupakan Programmer Java, karena saya sendiri baru memulai belajar bahasa pemrograman terutama PHP dan JavaScript .
Hasil dari mesin penghitung karakter tersebut adalah sebagai berikut:
1. Bahasa Indonesia (Menggunakan cerita pendek dari Hamdy Salad, dengan judul “Burung Terbang dari Kuburmu” terdiri dari 5.937 karakter)
Karakter yang paling sering muncul:
1. Huruf A muncul sebanyak 1.100 kali
2. Huruf N muncul sebanyak 573 kali
3. Huruf E muncul sebanyak 446 kali
4. Huruf I muncul sebanyak 406 kali
5. Huruf U muncul sebanyak 371 kali

2. Bahasa Inggris (Menggunakan cerita pendek dari Stepahn Crane,dengan judul “A Dark Brown Dog” terdiri dari 10.570 karakter)
Karakter yang paling sering muncul:
1. Huruf E muncul sebanyak 1.280 kali
2. Huruf T muncul sebanyak 936 kali
3. Huruf A muncul sebanyak 821 kali
4. Huruf H muncul sebanyak 764 kali
5. Huruf I muncul sebanyak 718 kali

3. Bahasa Sunda (Menggunakan cerita pendek dari Ally Ghiban,dengan judul “Nagaran Kuring Otong” terdiri dari 4.917 karakter)
Karakter yang Paling sering muncul:
1. Huruf A muncul sebanyak 829 kali
2. Huruf N muncul sebanyak 572 kali
3. Huruf U muncul sebanyak 400 kali
4. Huruf E muncul sebanyak 336 kali
5. Huruf G muncul sebanyak 308 kali

indonesia
inggris
sunda

Source Code Program:

 <style type=”text/css”>
<!–
.style1 {
                font-family: Verdana, Arial, Helvetica, sans-serif;
                font-size: 14px;
}
.style2 {
                font-size: 24px;
                color: #0000FF;
}
.style3 {color: #003399}
.style5 {
                font-size: 9;
                color: #000099;
}
–>
</style>
<div align=”left”><br>
  <br>
</div>
<p align=”left” class=”style1 style2″><strong>MESIN PENGHITUNG KARAKTER</strong></p>
<p align=”left” class=”style1″>&nbsp;</p>
<p align=”left” class=”style1 style3″><strong>Copy dan Paste Artikel Anda ke dalam Kotak Box dibawah ini:</strong></p>
<p align=”left” class=”style1 style5″><br />
  <textarea name=”myMessage” onkeyup=”menghitungChar(this.value)” rows=”20″ cols=”100″></textarea>
 
  <script language=”JavaScript”>
var cnt;
function menghitungChar(str) {
 
 var a = 0;
 var b = 0;
 var c = 0;
 var d = 0;
 var e = 0;
 var f = 0;
 var g = 0;
 var h = 0;
 var i = 0;
 var j = 0;
 var k = 0;
 var l = 0;
 var m = 0;
 var n = 0;
 var o = 0;
 var p = 0;
 var q = 0;
 var r = 0;
 var s = 0;
 var t = 0;
 var u = 0;
 var v = 0;
 var w = 0;
 var x = 0;
 var y = 0;
 var z = 0;
 var ii = 0;
 var array_jumlah_char = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
 var array_jumlah_char_x = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
 var array_char = new Array(“A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”I”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”U”,”V”,”W”,”X”,”Y”,”Z”);
 for(ii=0; ii<=str.length ;ii++){
                stringx = str.charAt(ii);
                if(stringx.toUpperCase() == “A”){
                                a++
                                array_jumlah_char[0] = a;
                                array_jumlah_char_x[0] = a;
                                print(“a”,a);
                }
                if(stringx.toUpperCase() == “B”){
                                b++
                                array_jumlah_char[1] = b;
                                array_jumlah_char_x[1] = b;
                                print(“b”,b);
                }
                if(stringx.toUpperCase() == “C”){
                                c++
                                array_jumlah_char[2] = c;
                                array_jumlah_char_x[2] = c;
                                print(“c”,c);
                }
                if(stringx.toUpperCase() == “D”){
                                d++
                                array_jumlah_char[3] = d;
                                array_jumlah_char_x[3] = d;
                                print(“d”,d);
                }
                if(stringx.toUpperCase() == “E”){
                                e++
                                array_jumlah_char[4] = e;
                                array_jumlah_char_x[4] = e;
                                print(“e”,e);
                }
                if(stringx.toUpperCase() == “F”){
                                f++
                                array_jumlah_char[5] = f;
                                array_jumlah_char_x[5] = f;
                                print(“f”,f);
                }
                if(stringx.toUpperCase() == “G”){
                                g++
                                array_jumlah_char[6] = g;
                                array_jumlah_char_x[6] = g;
                                print(“g”,g);
                }
                if(stringx.toUpperCase() == “H”){
                                h++
                                array_jumlah_char[7] = h;
                                array_jumlah_char_x[7] = h;
                                print(“h”,h);
                }
                if(stringx.toUpperCase() == “I”){
                                i++
                                array_jumlah_char[8] = i;
                                array_jumlah_char_x[8] = i;
                                print(“i”,i);
                }
                if(stringx.toUpperCase() == “J”){
                                j++
                                array_jumlah_char[9] = j;
                                array_jumlah_char_x[9] = j;
                                print(“j”,j);
                }
                if(stringx.toUpperCase() == “K”){
                                k++
                                array_jumlah_char[10] = k;
                                array_jumlah_char_x[10] = k;
                                print(“k”,k);
                }
                if(stringx.toUpperCase() == “L”){
                                l++
                                array_jumlah_char[11] = l;
                                array_jumlah_char_x[11] = l;
                                print(“l”,l);
                }
                if(stringx.toUpperCase() == “M”){
                                m++
                                array_jumlah_char[12] = m;
                                array_jumlah_char_x[12] = m;
                                print(“m”,m);
                }
                if(stringx.toUpperCase() == “N”){
                                n++
                                array_jumlah_char[13] = n;
                                array_jumlah_char_x[13] = n;
                                print(“n”,n);
                }
                if(stringx.toUpperCase() == “O”){
                                o++
                                array_jumlah_char[14] = o;
                                array_jumlah_char_x[14] = o;
                                print(“o”,o);
                }
                if(stringx.toUpperCase() == “P”){
                                p++
                                array_jumlah_char[15] = p;
                                array_jumlah_char_x[15] = p;
                                print(“p”,p);
                }
                if(stringx.toUpperCase() == “Q”){
                                q++
                                array_jumlah_char[16] = q;
                                array_jumlah_char_x[16] = q;
                                print(“q”,q);
                }
                if(stringx.toUpperCase() == “R”){
                                r++
                                array_jumlah_char[17] = r;
                                array_jumlah_char_x[17] = r;
                                print(“r”,r);
                }
                if(stringx.toUpperCase() == “S”){
                                s++
                                array_jumlah_char[18] = s;
                                array_jumlah_char_x[18] = s;
                                print(“s”,s);
                }
                if(stringx.toUpperCase() == “T”){
                                t++
                                array_jumlah_char[19] = t;
                                array_jumlah_char_x[19] = t;
                                print(“t”,t);
                }
                if(stringx.toUpperCase() == “U”){
                                u++
                                array_jumlah_char[20] = u;
                                array_jumlah_char_x[20] = u;
                                print(“u”,u);
                }
                if(stringx.toUpperCase() == “V”){
                                v++
                                array_jumlah_char[21] = v;
                                array_jumlah_char_x[21] = v;
                                print(“v”,v);
                }
                if(stringx.toUpperCase() == “W”){
                                w++
                                array_jumlah_char[22] = w;
                                array_jumlah_char_x[22] = w;
                                print(“w”,w);
                }
                if(stringx.toUpperCase() == “X”){
                                x++
                                array_jumlah_char[23] = x;
                                array_jumlah_char_x[23] = x;
                                print(“x”,x);
                }
                if(stringx.toUpperCase() == “Y”){
                                y++
                                array_jumlah_char[24] = y;
                                array_jumlah_char_x[24] = y;
                                print(“y”,y);
                }
                if(stringx.toUpperCase() == “Z”){
                                z++
                                array_jumlah_char[25] = z;
                                array_jumlah_char_x[25] = z;
                                print(“z”,z);
                }
 }
 
 var array_jumlah_char_rangking = new Array(5);
 array_jumlah_char_rangking = array_jumlah_char.sort(doCompare);
 array_jumlah_char_rangking = array_jumlah_char_rangking.reverse();
 array_jumlah_char_rangking = array_jumlah_char_rangking.slice(0,5);
 var array_char_terbesar = new Array(5);
 
 
 for(var xx=0 ; xx < array_jumlah_char_rangking.length ; xx++){
                for(var yy=0 ; yy < array_jumlah_char_x.length ; yy++){
                               
                                   if(array_jumlah_char_rangking[xx] == array_jumlah_char_x[yy]){
                      array_char_terbesar[xx] = array_char[yy];
                   }
                }
 }
print(“array_char_terbesar”,array_char_terbesar);
}
 
function doCompare(a,b) {
    return a – b
}
function print(chr,val) {
                var aa = document.getElementById(chr);
                aa.value = val;
}
document.write(“<br> <br> A : <input type=text id=a size=8 readonly>&nbsp;&nbsp; <br> <br> B : <input type=text id=b size=8 readonly>&nbsp;&nbsp; <br> <br> C : <input type=text id=c size=8 readonly>&nbsp;&nbsp; <br><br> D : <input type=text id=d size=8 readonly>&nbsp;&nbsp; <br><br>  E : <input type=text id=e size=8 readonly>&nbsp;&nbsp; <br><br> F: <input type=text id=f size=8 readonly>&nbsp;&nbsp; <br><br> G : <input type=text id=g size=8 readonly>&nbsp;&nbsp; <br><br> H : <input type=text id=h size=8 readonly>&nbsp;&nbsp; <br><br> I: <input type=text id=i size=8 readonly>&nbsp;&nbsp; <br><br> J : <input type=text id=J size=8 readonly>”);
document.write(“<br> <br> K : <input type=text id=k size=8 readonly>&nbsp;&nbsp; <br> <br>  L : <input type=text id=l size=8 readonly>&nbsp;&nbsp; <br> <br> M : <input type=text id=m size=8 readonly>&nbsp;&nbsp; <br><br> N : <input type=text id=n size=8 readonly>&nbsp;&nbsp; <br><br> O : <input type=text id=o size=8 readonly>&nbsp;&nbsp; <br><br> P : <input type=text id=p size=8 readonly>&nbsp;&nbsp; <br><br> Q : <input type=text id=q size=8 readonly>&nbsp;&nbsp; <br><br> R : <input type=text id=r size=8 readonly>&nbsp;&nbsp; <br><br> S : <input type=text id=s size=8 readonly>&nbsp;&nbsp; <br><br> T : <input type=text id=t size=8 readonly>”);
document.write(“<br><br> U : <input type=text id=u size=8 readonly>&nbsp;&nbsp; <br><br>  V : <input type=text id=v size=8 readonly>&nbsp;&nbsp; <br><br> W : <input type=text id=w size=8 readonly>&nbsp;&nbsp; <br><br> X : <input type=text id=X size=8 readonly>&nbsp;&nbsp; <br><br>  Y : <input type=text id=y size=8 readonly>&nbsp;&nbsp; <br><br> Z : <input type=text id=z size=8 readonly>”);
document.write(“<br> <br> Lima Karakter yang Paling Sering Muncul : <input type=text id=array_char_terbesar size=10 readonly>”);
 
 
  </script>
</p>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s