program Mesin_Karakter;
uses wincrt;
type
number = set of '0'..'9';
character= set of CHAR;
small = set of 'a'..'z';
big = set of 'A'..'Z';
var
berkas :text;
gede :big;
alit :small;
nom :number;
abjd,tdbc,opr :character;
a, p, i, t, s, b,o , Counter :INTEGER;
Ch :CHAR;
NamaFile :string[80];
procedure panggilfile(NF:string);
begin
ASSIGN(berkas, NF);
RESET(berkas);
end;
procedure tutup;
begin
close(berkas);
end;
procedure analisa;
begin
gotoxy(18,8);WRITE('MASUKKAN NAMA FILE YG AKAN DI TAMPILKAN : ');
gotoxy(18,11);write('.........................................');
gotoxy(18,10);readln(NamaFile);
CLRSCR;
panggilfile(NamaFile);
WRITELN;gotoxy(18,3);
WRITELN('ISI DARI FILE ','" ',NamaFile,' "',' ADALAH :');
WRITELN;
Counter := 0;
a := 0;
p := 0;
i := 0;
t := 0;
s := 0;
b := 0;
o := 0;
alit := ['a'..'z'];
gede := ['A'..'Z'];
abjd := alit + gede;
nom := ['0'..'9'];
tdbc:= [',',';','-','''','.','!','?',')','(','"',':','_'];
opr := ['+','-','*','/','='];
WHILE NOT EOF(berkas) DO
BEGIN
WHILE NOT EOLN(berkas) DO
BEGIN
READ(berkas,Ch);
WRITE(Ch);
Counter := Counter + 1;
IF Ch IN abjd THEN
BEGIN
a := a + 1;
IF Ch IN alit THEN
i := i + 1
ELSE IF Ch IN gede THEN
p := p + 1
END
ELSE IF Ch IN nom THEN
t := t + 1
ELSE IF Ch IN tdbc THEN
s := s + 1
ELSE IF Ch IN opr THEN
b := b + 1
ELSE
o := o + 1
END;
readln(berkas);
writeln
END;
tutup;
end;
procedure hasil;
begin
WRITELN;
gotoxy(15,9); WRITELN('###############################');
gotoxy(15,10);WRITELN(' Jumlah Huruf Kecil = ', i:5);
gotoxy(15,11);WRITELN(' Jumlah Huruf Kapital = ', p:5);
gotoxy(15,12);WRITELN('-------------------------------+');
gotoxy(15,13);WRITELN('1. JUMLAH HURUF = ', a:4);
gotoxy(15,14);WRITELN('-------------------------------');
gotoxy(15,15);WRITELN('2. JUMLAH BILANGAN ANGKA = ', t:4);
gotoxy(15,16);WRITELN('3. JUMLAH TANDA BACA = ', s:4);
gotoxy(15,17);WRITELN('4. JUMLAH OPERATOR MATEMATIKA = ', b:4);
gotoxy(15,18);WRITELN('5. JUMLAH SPASI = ', o:4);
gotoxy(15,19);WRITELN('###############################--------');
gotoxy(15,20);WRITELN(' TOTAL KARAKTER = ', Counter:5);
WRITELN;
end;
VAR Ul:char;
begin
REPEAT
CLRSCR;
analisa;
hasil;GOTOXY(15,22);
Write('Mau Ulang Lagi [Y/T]: ');Ul:=Upcase(Readkey);
Until Ul<>'Y';
END.
Jumat, 25 Maret 2011
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar