program bahasa pascal bagian 1


Program menentukan grade nilai mahasiswa

Program nilai_mahasiswa;
uses wincrt;
Var
Nilai : Real ;
Grade : Char ;
nama : string ;
Begin
write('NAMA: ',nama);
read(nama);
Write('NILAI ANDA : ');
.
Read(Nilai);

If Nilai > 85 Then
Grade := 'A'
else
If Nilai>65 Then
Grade := 'B'
Else
If Nilai > 55 Then
Grade := 'C'
Else
If Nilai > 40 Then
Grade := 'D'
Else
Grade := 'E' ;
Writeln(nama,' KETERANGANNYA : ',grade) ;
readln;
End.



program mencari persamaan kuadrat

Program Persamaan_Kuadrat;
Uses Wincrt;
label ulang;
Var A,B,C:integer;
D,X1,X2:real;
ab:char;
Begin
ulang:
clrscr;
Writeln('Program Persamaan Kuadrat');
Writeln('=========================');
Writeln;
Write('Masukkan Nilai A: ');readln(A);
Write('Masukkan Nilai B: ');readln(B);
Write('Masukkan Nilai C: ');readln(C);
Writeln;

D:=sqr(B)-(4*A*C);
if (D>0) then
begin
X1:=(-B+sqrt(D))/2*A;
X2:=(-B-sqrt(D))/2*A;
Writeln('X1= ',X1:4:1);
writeln('X2= ',X2:4:1);
end
else if (D=0) then
begin
X1:=-B/(2*A);
Writeln('X1=X2=',X1:4:1);
end
else
Writeln('Bukan Akar Real!');
writeln('Apakah anda ingin mengulanginya (y/t): ');
readln(ab);
if (ab='y') or (ab='Y') then
begin
goto ulang;
end
else
donewincrt;
readln
End.

program persamaan kuadrat 2
program mencari_akar_persamaan_kuadrat;
uses wincrt;

var
x1,x2:real;
a,b,c,d:integer;

begin
writeln('PROGRAM MENCARI AKAR PERSAMAAN KUADRAT ax^2+bx+c=0');
write('diketahui nilai a =');read(a);
write('diketahui nilai b =');read(b);
write('diketahui nilai c =');read(c);

d:=b*b-4*a*c;
if d<0 then writeln('tidak ada hasil akar real')
else
begin
x1:=(-b+(sqrt(d)))/2*a;
x2:=(-b-(sqrt(d)))/2*a;
writeln('x1= ',x1:4:2);
writeln('x2= ',x2:4:2);
end;

readln;
end.


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

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:= 0;
if (g1='coklat') then n1:=10;
if (g1='merah') then n1:=20;
if (g1='oranye') then n1:=30;
if (g1='kuning') then n1:=40;
if (g1='hijau') then n1:=50;
if (g1='biru') then n1:=60;
if (g1='ungu') then n1:=70;
if (g1='abu-abu')then n1:=80;
if (g1='putih') then n1:=90;

if (g2='hitam') then n2:=0;
if (g2='coklat') then n2:=1;
if (g2='merah') then n2:=2;
if (g2='oranye') then n2:=3;
if (g2='kuning') then n2:=4;
if (g2='hijau') then n2:=5;
if (g2='biru') then n2:=6;
if (g2='ungu') then n2:=7;
if (g2='abu-abu')then n2:=7;
if (g2='putih') then n2:=9;

if (g3='hitam') then n3:=1;
if (g3='coklat') then n3:=10;
if (g3='merah') then n3:=100;
if (g3='oranye') then n3:=1000;
if (g3='kuning') then n3:=10000;
if (g3='hijau') then n3:=100000;
if (g3='biru') then n3:=1000000;
if (g3='ungu') then n3:=10000000;
if (g3='abu-abu')then n3:=100000000;
if (g3='putih') then n3:=1000000000;
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:=5/100;


nilai:=((n1+n2)*n3);
nilaimax:=nilai+n4;
nilaimin:=nilai-n4;
writeln('nilai resistor = ',nilai :2:2,' ohm');
writeln('toleransi +/- ',n4:2:2);
writeln('nilai max resistor = ',nilaimax:2:2,' ohm');
writeln('nilai min resistor = ',nilaimin:2:2,' ohm');

readln;

donewincrt;
end.


program mencari nilai rata2
program rata_rata;
uses wincrt;

var
a, mahasiswa : integer;
nilai, total, tinggi, rendah, rata : real;
nama:string;

begin
total := 0;
write ('jumlah mahasiswa : '); readln (mahasiswa);
writeln;
for a := 1 to mahasiswa do
begin
write ('nama mahasiswa ke ',a,' ');readln (nama);
write ('nilai ',nama,' : '); readln (nilai);
total := total + nilai;
end;
rata := total / mahasiswa;
writeln ('rata-rata nilai mahasiswa : ',rata :1:2);
readln;
donewincrt
end.

Categories:

0 comments:

Post a Comment