Exersices 1
Dosen : Elisawati, S.Kom, M.Kom
Buatlah program dibawah ini dengan menggunakan tampilan 2 windows , windows sebelah Kiri Sebagai Input dan Windows Sebelah Kanan sebagai Output, Textcolor, Textbackground, Gotoxy, dan Sound untuk memperindah tampilan.
Mengubah derajat temperatur, dari derajat Celcius ke derajat Fahreinheit dan Reamur (derajat Celcius diinput
Menghitung Luas dan Keliling lingkaran, dengan jari-jari diketahui (diinput).
Menghitung Luas dan Keliling segitiga sembarang yang diketahui ke tiga sisinya.
Mencari nilai Sinus, Cosinus, dan Tangen dengan sudut diinput.
Mencari akar dan kuadrat dari suatu nilai (nilai diinput).
Mencari nilai bulat dan pecahan dari suatu nilai yang dimasuk kan melalui keyboard (diinput). Nilai pecahan tersebut dibulatkan sampai 3 angka dibelakang koma (,).
Jawaban :
Program Aritmatika;
uses crt;
var
a,ui : INTEGER; a1,a2,a3,b1 : REAL;
Label
screen,main,menu,input,output,input2,output2,
input3,output3,input4,output4,input5,output5,
input6,output6;
procedure fahrenheit;
var
f : real;
begin
f := 1.8 * ui + 32;
GOTOXY(41,2);writeln(' Suhu Fahreinheit ==> ',f:0:2);
end;
procedure reamur;
var
r : real;
begin
r := 0.8 * ui + 32;
GOTOXY(41,3);writeln(' Suhu Reamur ==> ',r:0:2);
end;
procedure Lingkaran;
Var
Keliling : REAL;
Luas : REAL;
begin
Luas := 3.14*ui*ui;
GOTOXY(41,2); writeln(' Luasnya : ', Luas:9:2);
keliling:=2*3.14*ui;
GOTOXY(41,3); writeln(' Kelilingnya : ', keliling:9:2);
end;
procedure Segitiga;
var
a,luas : real;
begin
a := sqrt(sqr(a1) + sqr(a2) -2 * a1 * a2 *cos(a3 / 57.2958));
luas := 0.5 * a1 * a2 * sin(a3 / 57.2958);
GOTOXY(41,2); writeln(' Luas Segitiga = ', luas:8:2);
GOTOXY(41,3); writeln(' Panjang Segitiga = ', a:8:2);
end;
procedure cosinus;
begin
GOTOXY(41,2); Write(' 1. Sinus : ', SIN(ui):9:3);
GOTOXY(41,3); Write(' 2. Cosinus : ', COS(ui):9:3);
GOTOXY(41,4); write(' 3. Tangen : ', ARCTAN(ui):9:3);
end;
procedure akar;
begin
GOTOXY(41,2); writeln(' Nilai X dipangkatkan : ', SQR(ui));
GOTOXY(41,3); writeln(' Nilai X diakarkan : ', SQRT(ui):1:0);
end;
procedure bulat;
begin
GOTOXY(41,2); writeln(' Bilangan Bulatnya : ', INT(b1):5:2);
GOTOXY(41,3); writeln(' Bilangan Pecahan : ', FRAC(b1):5:3);
end;
begin
repeat
goto screen;
screen:
clrscr;
goto menu;
menu: { Tampilan Menu }
textbackground(red);
textcolor(white);
window(1,3,80,13);
gotoxy(10,1); write(' Aritmatika ');
textbackground(0);
textcolor(black); textbackground(green);
GOTOXY(1,3); write(' Menu ');
textcolor(green); textbackground(0);
GOTOXY(1,4); write('1. Mengubah Derajat Temperatur !');
GOTOXY(1,5); write('2. Hitung Luas dan Keliling lingkaran');
GOTOXY(1,6); write('3. Hitung Luas dan Keliling segitiga');
GOTOXY(1,7); write('4. Nilai Sinus, Cosinus, dan Tangen');
GOTOXY(1,8); write('5. Akar dan kuadrat dari suatu nilai ');
GOTOXY(1,9); write('6. Nilai Bulat Dan Pecahan');
goto main;
main: { Tampilan Deskripsi }
textbackground(blue);
textcolor(white);
gotoxy(50,1); write(' STMIK DUMAI ');
textbackground(0);
textcolor(black); textbackground(green);
gotoxy(40,3); write(' Deskripsi ');
textcolor(green); textbackground(0);
gotoxy(40,4); write('');
gotoxy(40,5); write('Nama : Anda');
gotoxy(40,6); write('NIM : Anda');
gotoxy(40,7); write('Prodi : Teknik Informatika');
gotoxy(40,8); write('Dosen : Elisawati, M.kom');
gotoxy(40,9); write('');
gotoxy(40,10); write('');
GOTOXY(1,10); write('Please Select : '); readln(a);
until (a = 1) or (a = 2) or (a = 3) or (a = 4) or (a = 5) or ( a = 6);
if (a = 1) THEN { Algoritma Latihan 1 }
begin
clrscr;
goto input;
input:
window(1,3,40,13); { Tampilan Window Untuk Input }
textbackground(red);
textcolor(white);
GOTOXY(10,1); write(' Temperature input ');
textbackground(0); textcolor(green);
GOTOXY(1,3); write(' Masukan Suhu: '); readln(ui);
goto output;
output:
window(40,3,80,13); { Tampilan Window Untuk Output }
textbackground(blue);
textcolor(white);
GOTOXY(10,1); write(' HASIL ');
textbackground(0); textcolor(green);
fahrenheit; reamur;
window(1,3,80,13);
GOTOXY(1,11); write(' Press Enter To Continue...');readln();
goto screen;
end;
if (a = 2) THEN { Algoritma Latihan 2 }
begin
clrscr;
goto input2;
input2:
window(1,3,40,13); { Tampilan Window Untuk Input }
textbackground(red);
textcolor(white);
GOTOXY(10,1); write(' Calculator Input ');
textbackground(0); textcolor(green);
GOTOXY(1,3); write(' Masukan Lingkaran: '); readln(ui);
goto output2;
output2:
window(40,3,80,13); { Tampilan Window Untuk Output }
textbackground(blue);
textcolor(white);
GOTOXY(10,1); write(' HASIL ');
textbackground(0); textcolor(green);
Lingkaran;
window(1,3,80,13);
GOTOXY(1,11); write(' Press Enter To Continue...');readln();
goto screen;
end;
if (a = 3) THEN { Algoritma Latihan 3 }
begin
clrscr;
goto input3;
input3:
window(1,3,40,13); { Tampilan Window Untuk Input }
textbackground(red);
textcolor(white);
GOTOXY(10,1); write(' Calculator Input ');
textbackground(0); textcolor(green);
GOTOXY(1,3); write(' Luas Sisi 1 : '); readln(a3);
GOTOXY(1,4); write(' Luas Sisi 2 : '); readln(a1);
GOTOXY(1,5); write(' Luas Sisi 3 : '); readln(a2);
goto output3;
output3:
window(40,3,80,13); { Tampilan Window Untuk Output }
textbackground(blue);
textcolor(white);
GOTOXY(10,1); write(' HASIL ');
textbackground(0); textcolor(green);
Segitiga;
window(1,3,80,13);
GOTOXY(1,11); write(' Press Enter To Continue...');readln();
goto screen;
end;
if (a = 4) THEN { Algoritma Latihan 4}
begin
clrscr;
goto input4;
input4:
window(1,3,40,13); { Tampilan Window Untuk Input }
textbackground(red);
textcolor(white);
GOTOXY(10,1); write(' Calculator Input ');
textbackground(0); textcolor(green);
GOTOXY(1,3); write(' Masukkan Nilai : '); readln(ui);
goto output4;
output4:
window(40,3,80,13); { Tampilan Window Untuk Output }
textbackground(blue);
textcolor(white);
GOTOXY(10,1); write(' HASIL ');
textbackground(0); textcolor(green);
cosinus;
window(1,3,80,13);
GOTOXY(1,11); write(' Press Enter To Continue...');readln();
goto screen;
end;
if (a = 5) THEN { Algoritma Latihan 5}
begin
clrscr;
goto input5;
input5:
window(1,3,40,13); { Tampilan Window Untuk Input }
textbackground(red);
textcolor(white);
GOTOXY(10,1); write(' Calculator Input ');
textbackground(0); textcolor(green);
GOTOXY(1,3); write(' Masukkan Nilai Dari X : '); readln(ui);
goto output5;
output5:
window(40,3,80,13); { Tampilan Window Untuk Output }
textbackground(blue);
textcolor(white);
GOTOXY(10,1); write(' HASIL ');
textbackground(0); textcolor(green);
akar;
window(1,3,80,13);
GOTOXY(1,11); write(' Press Enter To Continue...');readln();
goto screen;
end;
if (a = 6) THEN {Algoritma Latihan 6}
begin
clrscr;
goto input6;
input6:
window(1,3,40,13); { Tampilan Window Untuk Input }
textbackground(red);
textcolor(white);
GOTOXY(10,1); write(' Calculator Input ');
textbackground(0); textcolor(green);
GOTOXY(1,3); write(' Masukkan Nilai : '); readln(b1);
goto output6;
output6:
window(40,3,80,13); { Tampilan Window Untuk Output }
textbackground(blue);
textcolor(white);
GOTOXY(10,1); write(' HASIL ');
textbackground(0); textcolor(green);
bulat;
window(1,3,80,13);
GOTOXY(1,11); write(' Press Enter To Continue...');readln();
goto screen;
end;
end.
Last updated
Was this helpful?