program resistor

program resistor;
uses wincrt;
var
nilai:real;
n1,n2,n3,n4,nilaimax,nilaimin:real;
g1,g2,g3,g4:string;

const
h=0;
c=1;
m=2;
o=3;
k=4;
hj=5;
b=6;

u=7;
a=8;
p=9;
e=1/2;
per=1.10;

begin
writeln('PROGRAM MENGETAHUI NILAI SUATU RESISTOR');
writeln('NAMA : AFIT MIRANTO');
writeln('NPM : G1D009001');
writeln('TEKNIK ELEKTRO UNIVERSITAS BENGKULU');
writeln(' ');
writeln('tulis warna gelang resistor dengan huruf kecil semua');
write('warna gelang 1= ');readln(g1);
write('warna gelang 2= ');readln(g2);
write('warna gelang 3= ');readln(g3);
write('warna gelang 4= ');readln(g4);

if (g1='hitam') then n1:=h;
if (g1='coklat') then n1:=c;
if (g1='merah') then n1:=m;
if (g1='oranye') then n1:=o;
if (g1='kuning') then n1:=k;
if (g1='hijau') then n1:=hj;
if (g1='biru') then n1:=b;
if (g1='ungu') then n1:=u;
if (g1='abu-abu')then n1:=a;
if (g1='putih') then n1:=p;

if (g2='hitam') then n2:=h;
if (g2='coklat') then n2:=c;
if (g2='merah') then n2:=m;
if (g2='oranye') then n2:=o;
if (g2='kuning') then n2:=k;
if (g2='hijau') then n2:=hj;
if (g2='biru') then n2:=b;
if (g2='ungu') then n2:=u;
if (g2='abu-abu')then n2:=a;
if (g2='putih') then n2:=p;


if (g3='hitam') then n3:=h;
if (g3='coklat') then n3:=c;
if (g3='merah') then n3:=m;
if (g3='oranye') then n3:=o;
if (g3='kuning') then n3:=k;
if (g3='hijau') then n3:=hj;
if (g3='biru') then n3:=b;
if (g3='ungu') then n3:=u;
if (g3='abu-abu')then n3:=a;
if (g3='putih') then n3:=p;
if (g3='perak') then n3:=0.01;
if (g3='emas') then n3:=0.1;

if (g4='perak') then n4:=10/100;
if (g4='emas') then n4:=50/100;


nilai:=((10*n1)+n2)*(exp(n3*ln(10)));
nilaimax:=nilai+n4;
nilaimin:=nilai-n4;
writeln('nilai resistor = ',nilai:4:2,' ohm');
writeln('toleransi +/- ',n4 :4:2);
writeln('nilaimax resistor = ',nilaimax:4:2,' ohm');
writeln('nilaimin resistor = ',nilaimin:4:2,' ohm');

readln;

donewincrt;
end.

Categories:

0 comments:

Post a Comment