Pages

Sabtu, 25 Desember 2010

TUGAS PETRUK : NILAI ANGKA >> NILAI HURUF NO.4 (ALGORITMA - PASCAL - HASIL )

  • ALGORITMA
algoritma nilai_huruf
deklarasi
   Nama,Nim,NH : string
   N1,N2,N3,N4,NA : real
deskripsi
begin
   read (Nama,Nim,N1,N2,N3,N4)
   NA ← (N1*0.15)+(N2*0.15)+(N3*0.35)+(N4*0.35)
   IF (NA >= 71) then
   NH ← 'A'
   else
   IF (NA >= 61) and (NA < 71) then
   NH ← 'B'
   else
   IF (NA >= 51) and (NA < 61) then
   NH ← 'C'
   else
   IF (NA >= 41) and (NA < 51) then
   NH ← 'D'
   else
   NH ← 'E'
endif
endif
endif
endif
    write(NA,NH)
end.
  • PASCAL
program nilai_huruf;
uses wincrt;
var
   nim,nama,n : string;
   a,b,c,d,na : real;
begin
writeln('      ---------------------------------------------- ');
writeln('             NILAI ANGKA  >>>  NILAI HURUF           ');
writeln('      ---------------------------------------------- ');
writeln;
write  ('       NAMA    : ');readln(nama);
write  ('       NIM     : ');readln(nim);
writeln;
write  ('       NILAI 1 = ');readln(a);
write  ('       NILAI 2 = ');readln(b);
write  ('       NILAI 3 = ');readln(c);
write  ('       NILAI 4 = ');readln(d);
na:=(a*0.15)+(b*0.15)+(c*0.35)+(d*0.35);

     if (na >=71) then
     n:='A';
     if (na>=61) and (na<70) then
     n:='B';
    
     if (na>=51) and (na<60) then
     n:='C';
                                                              
     if (na>=41) and (na<50) then
     n:='D';

     if (na<40) then
     n:='E';  
writeln;
writeln('      ---------------------------------------------- ');
writeln;
writeln('       NILAI ANGKA = ',na:2:2);
writeln('       NILAI HURUF = ',n) ;
writeln;
writeln('      ---------------------------------------------- ');
end.
  • HASIL
Photobucket

Print Friendly and PDF

Artikel Terkait:

0 komentar:

Posting Komentar

Related Posts Plugin for WordPress, Blogger...