Anda di halaman 1dari 87

LAPORAN PROGRAM KOMPUTER 1

Disusun Oleh :

- Ari Reza Koswara (10872)


- Gatot Yudhanto (12283)

pg. 1
DAFTAR ISI

i. Cover…………………………………………………………...…1
ii. Daftar Isi………………………………………………………….2
iii. Tugas Console……………………………………………………5
Tugas 1……………………………………………………...5
Tugas 2……………………………………………………...6
Tugas 3……………………………………………………...8
Tugas 4……………………………………………………...9
Tugas 5…………………………………………………….11
Tugas 6…………………………………………………….12
Tugas 7…………………………………………………….15
Tugas 8…………………………………………………….16
Tugas 9…………………………………………………….18
Tugas 10…………………………………………………...20
iv. Tugas Visual…………………………………………………….22
Tugas 11…………………………………………………...22
Tugas 12…………………………………………………...23
Tugas 13…………………………………………………...26
Tugas 14…………………………………………………...27
Tugas 15…………………………………………………...29
Tugas 16…………………………………………………...31
pg. 2
Tugas 17…………………………………………………...33
Tugas 18…………………………………………………...34
Tugas 19…………………………………………………...37
Tugas 20…………………………………………………...38
Tugas 21…………………………………………………...41
Tugas 22…………………………………………………...43
v. PR Ari Reza Koswara…………………………………………..46
PR 01………………………………………………………46
PR 02………………………………………………………47
PR 03………………………………………………………48
PR 04………………………………………………………50
PR 05………………………………………………………51
PR 06………………………………………………………53
PR 07………………………………………………………54
PR 08………………………………………………………56
PR 09………………………………………………………58
PR 10………………………………………………………59
PR 11………………………………………………………60
PR 12………………………………………………………62
vi. PR Gatot Yudhanto…………………………………………….65
PR 01………………………………………………………65
PR 02………………………………………………………66

pg. 3
PR 03………………………………………………………68
PR 04………………………………………………………69
PR 05………………………………………………………71
PR 06………………………………………………………72
PR 07………………………………………………………74
PR 08………………………………………………………75
PR 09………………………………………………………78
PR 10………………………………………………………79
PR 11………………………………………………………81
PR 12………………………………………………………84

pg. 4
Tugas dan PR Prokom

30 Oktober 2016 – 11 November 2016

Tugas

Nama : Ari Reza Koswara & Gatot Yudhanto

TUGAS CONSOLE

1. Program Menghitung Harga Yang Terkena Diskon

pg. 5
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()
{
//type data
float Bila,Diskon5,HargaD10,HargaD5,Diskon10;
printf("Menghitung harga yang terkena Diskon\n");
printf("Dibuat oleh Ari dan Gatot\n Nim 10872 dan 12283\n");
printf("======================================\n\n");

//input
printf("Masukkan harga Pembelian = ");
scanf("%f",&Bila);

//Procces

if(Bila>=100000)
{printf("\nMendapatkan diskon 10 %% ");
Diskon10=Bila*0.1;
HargaD10=Bila-(Bila*0.1);
printf("\nPotongan diskon = %.2f",Diskon10);
printf("\nHarga setelah di diskon 10%% = %.2f",HargaD10);
}

if(Bila<100000)
{printf("Mendapatkan diskon 5 %% ");
Diskon5=Bila*0.05;
HargaD5=Bila-(Bila*0.05);
printf("\nPotongan diskon = %.2f",Diskon5);
printf("\nHarga setelah di diskon 5%% = %.2f",HargaD5);
}

getch();
}

2. Program Pembaruan Nilai Hasil Ujian

pg. 6
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()

{
float X;

printf("pembaruan nilai hasil ujian\n");


printf("Dibuat oleh Gatot dan Ari\n Nim 12283 dan 10872\n");
printf("======================================\n");

printf("Masukkan nilai anda = ");


scanf("%f",&X);

if( X>85 && X<=100)


{printf("anda mendapat nilai A");
}
if(X>70 && X<=84)
{printf("anda mendapat nilai B");
}
if(X>55 && X<=69)

pg. 7
{printf("anda mendapat nilai C");
}
if(X>30 && X<=54)
{printf("anda mendapat nilai D");
}
if(X>=0 && X<=29)
{printf("anda mendapat nilai E");
}
if (X>100)
{printf("data tidak valid");
}
if (X<0)
{printf("data tidak valid");
}

getch();
}

3. Program Menghitung Luas

Berikut Program Console nya :

#include <stdio.h>

pg. 8
#include <conio.h>

void main()
{
float alas,tinggi,panjang,lebar,Pi,r,luas;
int menu;

printf("Menghitung luas\n");
printf("Dibuat oleh Ari dan Gatot\n Nim 10872 dan 12283\n");
printf("======================================\n\n");

printf("1. Menghitung Luas Segitiga\n");


printf("2. Menghitung Luas Segiempat\n");
printf("3. Menghitung Luas Lingkaran\n");

printf("Pilih Luas Yang Dihitung (1/2/3)\n\n");scanf("%d",&menu);


if (menu==1)
{
printf("Hitung Luas Segitiga\n\n");
printf("Masukan Alas (m)=");scanf("%f",&alas);
printf("Masukan Tinggi (m)=");scanf("%f",&tinggi);
luas=(alas*tinggi)/2;
printf("Luas Segitiga = %.1f m^2\n",luas);
}
else if(menu==2)
{
printf("Hitung Luas Segiempat\n\n");
printf("Masukan Panjang (m)=");scanf("%f",&panjang);
printf("Masukan Lebar (m)=");scanf("%f",&lebar);
luas=panjang*lebar;
printf("Luas Segiempat = %.1f m^2\n",luas);
}
else if(menu==3)
{
printf("Hitung Luas Lingkaran\n\n");
printf("Masukan jari-jari=");scanf("%f",&r);
luas=3.14*r*r;
printf("Luas Lingkaran = %.1f m^2\n",luas);
}
else
{
printf("ERROR404\n");
}
getch();

4. Program Menghitung Trigonometri

pg. 9
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()
{
float sinA,cosA,tanA,X;
int no;

printf("Menghitung TRIGONOMETRI\n");
printf("Dibuat oleh Gatot dan Ari\n Nim 12283 dan 10872\n");
printf("=======================\n");

printf("\nPilihan menu hitung\n1.Hitung Sinus\n2.Hitung Cosinus\n3.Hitung


Tangen\n");
printf("\nPilih menu yang diinginkan = ");;scanf("%d",&no);

if (no==1)
{printf(" Menghitung Sin");
printf(" Masukkan nilai = ");scanf("%f",&X);
sinA=sin(X/57.2958);
printf(" Jadi nilainya adalah = %.1f",sinA);
}
else if (no==2)

pg. 10
{printf(" Menghitung Cos");
printf(" Masukkan nilai = ");scanf("%f",&X);
cosA=cos(X/57.2958);
printf(" Jadi nilainya adalah = %.1f",cosA);
}
else if (no==3)
{printf(" Menghitung Tan");
printf(" Masukkan nilai = ");scanf("%f",&X);
tanA=tan(X/57.2958);
{
if (X==90||X==270)
printf("Jadi nilainya adalah = inf");
else
printf(" Jadi nilainya adalah = %.1f",tanA);
}

}
else
printf("ERROR!!!!!!!!!!!!!");

getch();
}

5. Program Menghitung Temperatur

Berikut Program Console nya :


pg. 11
#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()
{
float Celcius,Reamur,Faranheit;
int menu;

printf(" Program Hitung Temperature\n");


printf(" Oleh : Ari <02> & Gatot <19>\n");
printf(" ==========================\n\n");

printf(" Pilihan menu temperature\n 1. Celcius Ke Reamur\n 2. Celcius ke


Faranheit\n 3. Reamur ke Faranheit\n");
printf("\n Pilih Menu Temperature <1,2,3> = ");scanf("%d",&menu);

switch (menu)
{
case 1:
printf(" Hitung Celcius ke Reamur\n");
printf(" ------------------------\n");
printf(" input Celcius = ");scanf("%f",&Celcius);
Reamur=Celcius*4/5;
printf(" %.2f Reamur",Reamur);
break;

case 2:
printf(" Hitung Celcius ke Faranheit\n");
printf(" ------------------------\n");
printf(" input Celcius = ");scanf("%f",&Celcius);
Faranheit=(Celcius*9/5)+32;
printf(" %.2f Faranheit",Faranheit);
break;

case 3:
printf(" Hitung Reamur ke Faranheit\n");
printf(" ------------------------\n");
printf(" input Reamur = ");scanf("%f",&Reamur);
Faranheit=(Reamur*9/4)+32;
printf(" %.2f Faranheit",Faranheit);
break;

default:
printf(" \n Input Menu Yang Dimasukkan Salah");
}

getch();
}

6. Program Soal Fisika


pg. 12
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ()

{
int num,number;
float Vawal,Teta,Waktu,Kp,KedP,g,Vt,a;
printf(" Program Soal Fisika\n");
printf(" Dibuat oleh Ari dan Gatot\n Nim 10872 dan 12283\n");
printf(" ======================================\n\n");

printf(" Pilihan Menu");


printf(" \n 1.Gerak Peluru");
printf(" \n 2.GLBB\n\n");

printf(" Pilih Menu Soal Fisika<1/2> =");


scanf("%d",&num);

switch(num)

pg. 13
{
case 1:
printf("\n\n Gerak Peluru");
printf("\n =================");
printf("\n 1.Gerak Terhadap Sumbu X");
printf("\n 2.Gerak Terhadap Sumbu Y");
printf("\n\n Pilih Gerak Peluru<1/2> = ");
scanf("%d",&number);

switch(number)
{
case 1:
printf("\n\n Gerak Peluru Terhadap Sumbu X");
printf("\n =============================");
printf("\n\n Input Vo= ");
scanf("%f",&Vawal);
printf("\n Input Sudut Teta= ");
scanf("%f",&Teta);
printf("\n Input Waktu= ");
scanf("%f",&Waktu);
Kp=Vawal*cos(Teta/57.2958);
KedP=Vawal*cos(Teta/57.2958)*Waktu;
printf(" Kecepatan Peluru= %.2f",Kp);
printf("\n Kedudukan Peluru= %.2f",KedP);
break;
case 2:
printf("\n\n Gerak Peluru Terhadap Sumbu Y");
printf("\n =============================");
printf("\n\n Input Vo= ");
scanf("%f",&Vawal);
printf("\n Input Sudut Teta= ");
scanf("%f",&Teta);
printf("\n Input Waktu= ");
scanf("%f",&Waktu);
printf(" Input gravitasi=");
scanf("%f",&g);
Kp=Vawal*sin(Teta/57.2958)-(g*Waktu);
KedP=Kp*Waktu-(0.5*g*Waktu*Waktu);
printf(" Kecepatan Peluru= %.2f",Kp);
printf("\n Kedudukan Peluru= %.2f",KedP);
break;
default:
printf(" Kode Tidak ada!!!");
}
break;

case 2 :

printf ("\n\n Gerak Lurus Berubah Beraturan");


printf ("\n ===============================");
printf ("\n Masukan Vo = ");scanf ("%f",&Vawal);
printf (" Masukan Vt = ");scanf ("%f",&Vt);
printf (" Masukan t = ");scanf ("%f",&Waktu);
a=(Vt-Vawal)/Waktu;
printf ("\n a = %.2f",a);

pg. 14
if (a<0)
printf ("\n Gerak Diperlambat");
if (a>0)
printf ("\n Gerak Dipercepat");
if (a==0)
printf ("\n Gerak Konstan");
break;
default:
printf("\n Kode Tidak ada!!!");

getch();
}

7. Program Tabel Suhu

Berikut Program Console nya :


pg. 15
#include <stdio.h>
#include <conio.h>
#include <math.h>

void main ()
{
int i,n;

float aw,ak,inter,c,r,f,k;

printf(" Tabel Suhu\n");


printf(" oleh : Ari Reza K (2) dan Gatot Yudhanto (19)\n");
printf(" ====================================\n\n");

printf(" Masukan Farenheit awal = ");scanf("%f",&aw);


printf(" Masukan Farenheit akhir = ");scanf("%f",&ak);
printf(" Masukan interval = ");scanf("%f",&inter);
printf(" ------------------------------------------\n");
printf(" | No | F | C | R | K |\n");
printf(" ------------------------------------------\n");

n=(ak-aw)/inter;

for(i=0;i<=n;i=i+1)
{
f=aw+(i*inter);
c=(f-32)*5/9;
r=(f-32)*4/9;
k=c+273;
printf(" | %3d | %3.2f | %3.2f | %4.2f | %4.2f |\n",i+1,f,c,r,k);
}
printf(" -----------------------------------------\n");
getch();
}

8. Program Tabel Trigonometri

pg. 16
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()

{
float sudut,t,s,m,sa,sk,i,r;
int n;

printf(" Program Tabel Trigonometri\n");


printf(" Oleh : Ari Reza(2) dan Gatot Yudhanto(19)\n");
printf(" ========================================\n\n");

printf("\n Masukkan Sudut Awal = ");scanf("%f",&sa);


printf("\n Masukkan Sudut Akhir = ");scanf("%f",&sk);
printf("\n Masukkan Interval = ");scanf("%f",&i);

r=(sk-sa)/i;
printf("\n Tabel Trigonometri\n");
printf(" --------------------------------------------------------\n");
printf(" | NO | Sudut | Tangen | Cosinus | Sinus |\n");
printf(" --------------------------------------------------------\n");

pg. 17
for (n=0;n<=r;n=n+1)
{
sudut=sa+(n*i);
t=sin(sudut/57.2958);
s=cos(sudut/57.2958);
m=tan(sudut/57.2958);

if(sudut==90)
printf(" | %2.d | %6.2f | inf | %6.2f | %6.2f
|\n",n+1,sudut,s,t);
else if(sudut==270)
printf(" | %2.d | %6.2f | inf | 0.00 | %6.2f
|\n",n+1,sudut,t);
else if (sudut==180)
printf(" | %2.d | %6.2f | 0.00 | %6.2f | %6.2f
|\n",n+1,sudut,s,t);
else if (sudut==360)
printf(" | %2.d | %6.2f | 0.00 | %6.2f | 0.00
|\n",n+1,sudut,s);
else
printf(" | %2.d | %6.2f | %6.2f | %6.2f | %12.2f |\n",n+1,sudut,m,s,t);

printf(" --------------------------------------------------------\n");

getch();

9. Program Tabel Mekanika Struktur

pg. 18
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>

void main ()
{
float a,b,i,l,p,r,Mc,Rva,Rvb,Status,x;
int n;

printf (" Program Tabel Mekanika Struktur\n");


printf (" Ari Reza(02) & Gatot Yudhanto(19) \n");
printf (" =================================\n\n");

printf (" Masukan Jarak Awal (x) = ");scanf ("%f",&a);


printf (" Masukan Jarak Akhir (x) = ");scanf ("%f",&b);
printf (" Masukan Interval = ");scanf ("%f",&i);
printf (" Masukan Panjang Batang (L) = ");scanf ("%f",&l);
printf (" Masukan Gaya (P) = ");scanf ("%f",&p);

if (a>b)
printf ("\nNilai x Awal < x Akhir !!!");
else if (l<b)
printf ("\nNilai L < x akhir !!!");
else
{
r=(b-a)/i;
printf ("\n Tabel Mekanika Struktur ");
pg. 19
printf ("\n ==============================================================");
printf ("\n | NO | x | Mc | Rva | Rvb | Status |");
printf ("\n ==============================================================");

for(n=0;n<=r;n=n+1)
{
x=a+(n*i);
Rvb=(x/l)*p;
Rva=p-Rvb;
Mc=Rva*x;
if (Rva>Rvb)
printf ("\n | %3d | %4.0f | %8.2f | %8.2f | %8.2f | Rva > Rvb
|",n+1,x,Mc,Rva,Rvb);
else if (Rva<Rvb)
printf ("\n | %3d | %4.0f | %8.2f | %8.2f | %8.2f | Rva < Rvb
|",n+1,x,Mc,Rva,Rvb);
else
printf ("\n | %3d | %4.0f | %8.2f | %8.2f | %8.2f | Rva = Rvb
|",n+1,x,Mc,Rva,Rvb);
}
printf ("\n ==============================================================");
}

getch ();
}

10. Program Pinjaman Syariah

Berikut Program Console nya :


pg. 20
#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()

{
int n,i,no;
float r,a,b,c,x,k;

printf(" \n Program Pinjaman Syariah");


printf(" \n Dibuat oleh Gatot (19) dan Ari (02)");
printf(" \n =======================================\n");

printf(" \n Input Rupiah < 10 juta smp 50 juta > = ");scanf("%f",&r);

if (r<10000000)
printf ("\n\n\n ***** Nominal Rupiah Tidak Memenuhi !!! *****");
else if (r>50000000)
printf ("\n\n\n ***** Nominal Rupiah Tidak Memenuhi !!! *****");

else
{
printf("\n\n Tabel Pinjaman");
printf("\n|==========================================================|\n");
printf("| No | Rp | 5x | 10x | Bonus |\n");
printf("|==========================================================|\n");

i=r/5000000;

for (n=0;n<i-1;n=n+1)

{
no=n+1;
x=r-(n*5000000);

a=x/5;
b=x/10;

if (x>=40000000&&x<=50000000)

printf("|%4d| %6.0f | %11.0f | %12.0f | Rp%9.0f |\n",no,x,a,b,x*0.01);


if (x>=20000000&&x<40000000)
printf("|%4d| %6.0f | %11.0f | %12.0f | Hp china |\n",no,x,a,b);
if (x<20000000)
printf("|%4d| %6.0f | %11.0f | %12.0f | No bonus |\n",no,x,a,b);

}
printf("|==========================================================|\n");
}

getch();
}

pg. 21
TUGAS VISUAL

11. Program Tabel Energi

Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

float m,v,g,h,EP,EK,EM;

if (listBox1->SelectedIndex == 0) m=100;
if (listBox1->SelectedIndex == 1) m=200;
if (listBox1->SelectedIndex == 2) m=300;

if (listBox2->SelectedIndex == 0) v=10;
if (listBox2->SelectedIndex == 1) v=20;

pg. 22
if (listBox2->SelectedIndex == 2) v=30;

if (radioButton1->Checked) g=10;
if (radioButton2->Checked) g=9.8;

if (comboBox1->SelectedIndex == 0) h=10;
if (comboBox1->SelectedIndex == 1) h=20;
if (comboBox1->SelectedIndex == 2) h=30;

if(m==0)
MessageBox::Show("masukkan massa !!");
else if(v==0)
MessageBox::Show("masukkan kecepatan !!");
else if(g==0)
MessageBox::Show("masukkan gravitasi !!");
else if(h==0)
MessageBox::Show("masukkan ketinggian !!");
else
{
EP=m*g*h;
EK=0.5*m*v*v;
EM=EP+EK;

label2->Text=Convert::ToString(EK);
label4->Text=Convert::ToString(EP);
label6->Text=Convert::ToString(EM);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

listBox1->SelectedIndex=-1;
listBox2->SelectedIndex=-1;

radioButton1->Checked=false;
radioButton2->Checked=false;

comboBox1->SelectedIndex=-1;

label2->Text="XXXXXX";
label4->Text="XXXXXX";
label6->Text="XXXXXX";

}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
Close();

12. Program Rangkaian Listrik

pg. 23
Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)


{

float rs,rp,as,ap,ds,dp,st,r1,r2,r3,v;

if (comboBox1->SelectedIndex == 0) r1= 10;


if (comboBox1->SelectedIndex == 1) r1= 20;
if (comboBox1->SelectedIndex == 2) r1= 30;

if (comboBox2->SelectedIndex == 0) r2= 5;
if (comboBox2->SelectedIndex == 1) r2= 15;
if (comboBox2->SelectedIndex == 2) r2= 25;

if (listBox1->SelectedIndex == 1) v= 220;
if (listBox1->SelectedIndex == 2) v= 110;

if (radioButton1->Checked) r3= 10;


if (radioButton2->Checked) r3= 15;
if (radioButton3->Checked) r3= 20;
if (radioButton4->Checked) r3= 25;

if (r1==0)
MessageBox::Show("Masukan R1!!!");
else if (r2==0)
MessageBox::Show("Masukan R2!!!");\
else if (r3==0)
pg. 24
MessageBox::Show("Masukan R3!!!");
else if (v==0)
MessageBox::Show("Tegangan Harus Diisi!!!");

else
{

rs= r1+r2+r3;
rp= (r1*r2*r3)/((r2*r3)+(r1*r3)+(r1*r2));
as= v/rs;
ap= v/rp;
ds= as*v;
dp= ap*v;

label6->Text = Convert::ToString(rs);
label7->Text = Convert::ToString(rp);
label10->Text = Convert::ToString(as);
label11->Text = Convert::ToString(ap);
label14->Text = Convert::ToString(ds);
label15->Text = Convert::ToString(dp);

if (v==220)
label17->Text = "Tegangan Tinggi";
else
label17->Text = "tegangan Rendah";
}

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->SelectedIndex=-1;
comboBox2->SelectedIndex=-1;
listBox1->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;

label5->Text ="xxxxxxx";
label7->Text = "xxxxxxx";
label10->Text = "xxxxxxx";
label11->Text = "xxxxxxx";
label14->Text = "xxxxxxx";
label15->Text = "xxxxxxx";
label17->Text = "xxxxxxx";
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

Close ();
}

pg. 25
13. Program GLBB

Berikut Program Visual nya :

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

Close();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->SelectedIndex=-1;
comboBox2->SelectedIndex=-1;

radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;

label5->Text="XXXXXX";
label6->Text="XXXXXX";
label7->Text="XXXXXX";

pg. 26
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

float Vo,Vt,t,a,s;

if (comboBox1->SelectedIndex == 1) Vo=10;
if (comboBox1->SelectedIndex == 2) Vo=20;
if (comboBox1->SelectedIndex == 3) Vo=30;

if (comboBox2->SelectedIndex == 1) Vt=10;
if (comboBox2->SelectedIndex == 2) Vt=20;
if (comboBox2->SelectedIndex == 3) Vt=30;

if (radioButton1->Checked) t=10;
if (radioButton2->Checked) t=20;
if (radioButton3->Checked) t=30;
if (radioButton4->Checked) t=40;

if(Vo==0)
MessageBox::Show("Input Vo harus diisi!!");
else if(Vt==0)
MessageBox::Show("Input Vt harus diisi!!");
else if(t==0)
MessageBox::Show("Input t harus diisi!!");
else
{
a=(Vt-Vo)/t;
s=Vo*t+0.5*a*t*t;

if (a>0)
label7->Text = "Dipercepat";
else if (a<0)
label7->Text = "Diperlambat";
else
label7->Text = "Konstan";
label5->Text=Convert::ToString(a);
label6->Text=Convert::ToString(s);
}
}

14. Program Akar Persamaan Kuadrat

pg. 27
Berikut Program Visual nya :

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->SelectedIndex=-1;
comboBox2->SelectedIndex=-1;
comboBox3->SelectedIndex=-1;

label8->Text="xxxxxx";
label9->Text="xxxxxx";
label10->Text="xxxxxx";
label11->Text="xxxxxx";

}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

float a,b,c,D,xa,xb;

if (comboBox1->SelectedIndex == 0) a=1;
if (comboBox1->SelectedIndex == 1) a=3;
if (comboBox1->SelectedIndex == 2) a=4;

if (comboBox2->SelectedIndex == 0) b=1;
if (comboBox2->SelectedIndex == 1) b=4;
if (comboBox2->SelectedIndex == 2) b=6;

if (comboBox3->SelectedIndex == 0) c=1;
if (comboBox3->SelectedIndex == 1) c=3;
pg. 28
if (comboBox3->SelectedIndex == 2) c=5;

if (a==0)
MessageBox::Show("Input a tidak boleh nol !!");
else if (b==0)
MessageBox::Show("Input b tidak boleh nol !!");
else if (c==0)
MessageBox::Show("Input c tidak boleh nol !!");
else

{
D=pow(b,2)-4*a*c;
if (D<0)
{
xa=(-b+sqrt(-D))/(2*a);
xb=(-b-sqrt(-D))/(2*a);
}
if (D>=0)
{
xa=(-b+sqrt(D))/(2*a);
xb=(-b-sqrt(D))/(2*a);
}

label8->Text=Convert::ToString(D);
label9->Text=Convert::ToString(xa);
label10->Text=Convert::ToString(xb);

if (D>0)
label11->Text = "Dua Akar Real";
else if (D<0)
label11->Text = "Dua Akar Imaginer";
else
label11->Text = "Dua Akar Kembar";
}

15. Program Konversi Suhu

pg. 29
Berikut Program Visual nya :

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)


{
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
float f,r,k;

if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text=="")


MessageBox::Show("Input Tidak Boleh Kosong !!!");

if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text!="")


MessageBox::Show("Input Tidak Boleh Tiga !!!");

if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text=="")


MessageBox::Show("Input Tidak Boleh Dua !!!");

if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text!="")


MessageBox::Show("Input Tidak Boleh Dua !!!");

if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text!="")


MessageBox::Show("Input Tidak Boleh Dua !!!");

if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text=="")


pg. 30
{
f=Convert::ToDouble(textBox1->Text);
r=(f-32)*4/9;
k=((f-32)*5/9)+273;
textBox2->Text = Convert::ToString(r);
textBox3->Text = Convert::ToString(k);
}

if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text=="")


{
r=Convert::ToDouble(textBox2->Text);
f=(r*9/4)+32;
k=(r*5/4)+273;
textBox1->Text = Convert::ToString(f);
textBox3->Text = Convert::ToString(k);
}

if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text!="")


{
k=Convert::ToDouble(textBox3->Text);
f=((k-273)*9/5)+32;
r=(k-273)*4/5;
textBox1->Text = Convert::ToString(f);
textBox2->Text = Convert::ToString(r);
}
}

16. Program Segitiga ABC

pg. 31
Berikut Program Visual nya :

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)


{
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
float a,t,m;

if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text=="")


MessageBox::Show("Input Tidak Boleh Kosong !!!");
else if(textBox1->Text!="" && textBox2->Text!="" && textBox3-
>Text!="")
MessageBox::Show("Input Tidak Boleh Tiga !!!");
else if(textBox1->Text!="" && textBox2->Text=="" && textBox3-
>Text=="")
MessageBox::Show("Input AB atau BC !!!");
else if(textBox1->Text=="" && textBox2->Text!="" && textBox3-
>Text=="")
MessageBox::Show("Input AC atau BC !!!");
else if(textBox1->Text=="" && textBox2->Text=="" && textBox3-
>Text!="")
MessageBox::Show("Input AC atau AB !!!");
else
{
if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text=="")
{
m=Convert::ToDouble(textBox1->Text);
t=Convert::ToDouble(textBox2->Text);
a=sqrt((m*m)-(t*t));
textBox3->Text = Convert::ToString(a);
}
if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text!="")
{
m=Convert::ToDouble(textBox1->Text);
a=Convert::ToDouble(textBox3->Text);
t=sqrt((m*m)-(a*a));
textBox2->Text = Convert::ToString(t);
}
if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text!="")
{
t=Convert::ToDouble(textBox2->Text);
a=Convert::ToDouble(textBox3->Text);
m=sqrt((t*t)+(a*a));
textBox1->Text = Convert::ToString(m);
}
}
}

pg. 32
17. Program GLBB

Berikut Program Visual nya :

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)


{
comboBox1->SelectedIndex=-1;
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
label7->Text="xxxxxx";
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
{
Close();
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
double t,Vt,Vo,a;
{
if (comboBox1->SelectedIndex == 1) t=10;
else if (comboBox1->SelectedIndex == 2) t=20;
else if (comboBox1->SelectedIndex == 3) t=30;
else
{MessageBox::Show("Input t harus diisi!!");
}
pg. 33
}

if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text!="")


MessageBox::Show("Input Tidak Boleh Tiga !!!");
if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text=="")
MessageBox::Show("Input Tidak Boleh Kosong !!!");
if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text=="")
MessageBox::Show("Input kurang Vt atau a !!!");
if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text=="")
MessageBox::Show("Input kurang Vo atau a !!!");
if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text!="")
MessageBox::Show("Input kurang Vo atau Vt !!!");

if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text=="")


{
Vo=Convert::ToDouble(textBox1->Text);
Vt=Convert::ToDouble(textBox2->Text);
a=(Vt-Vo)/t;
if (a<0)
label7->Text = "Diperlambat";
else if (a>0)
label7->Text = "Dipercepat";
else
label7->Text = "Konstan";
textBox3->Text = Convert::ToString(a);
}
if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text!="")
{
Vo=Convert::ToDouble(textBox1->Text);
a=Convert::ToDouble(textBox3->Text);
Vt=Vo+(a*t);
textBox2->Text = Convert::ToString(Vt);
}
if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text!="")
{
Vt=Convert::ToDouble(textBox2->Text);
a=Convert::ToDouble(textBox3->Text);
Vo=Vt-(a*t);
textBox1->Text = Convert::ToString(Vo);
}

18. Program Tabel Energi

pg. 34
Berikut Program Visual nya :

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)


{
Close();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
comboBox1->SelectedIndex=-1;
comboBox2->SelectedIndex=-1;
comboBox3->SelectedIndex=-1;
comboBox4->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
listBox1->SelectedIndex=-1;
dataGridView1->RowCount=1;
dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
dataGridView1->Rows[0]->Cells[3]->Value="";
dataGridView1->Rows[0]->Cells[4]->Value="";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int n,i;
float inter,no,ma,mk,v,g,h,ek,ep,em,x;
pg. 35
if(comboBox1->SelectedIndex==-1)
MessageBox::Show("Input m awal!");
else if(comboBox2->SelectedIndex==-1)
MessageBox::Show("Input m akhir!");
else if (radioButton1->Checked==false&&radioButton2-
>Checked==false)
MessageBox::Show("Input interval!");
else if(comboBox3->SelectedIndex==-1)
MessageBox::Show("Input ketinggian!");
else if(comboBox4->SelectedIndex==-1)
MessageBox::Show("Input kecepatan!");
else if (listBox1->SelectedIndex==-1)
MessageBox::Show("Input gravitasi!");

else
{
if (comboBox1->SelectedIndex == 1) ma=10;
if (comboBox1->SelectedIndex == 2) ma=20;
if (comboBox1->SelectedIndex == 3) ma=30;

if (comboBox2->SelectedIndex == 1) mk=100;
if (comboBox2->SelectedIndex == 2) mk=120;
if (comboBox2->SelectedIndex == 3) mk=140;

if (radioButton1->Checked) inter=1;
if (radioButton2->Checked) inter=2;

if (comboBox3->SelectedIndex == 1) h=10;
if (comboBox3->SelectedIndex == 2) h=20;
if (comboBox3->SelectedIndex == 3) h=30;

if (listBox1->SelectedIndex == 1) g=9.8;
if (listBox1->SelectedIndex == 2) g=10;

if (comboBox4->SelectedIndex == 1) v=10;
if (comboBox4->SelectedIndex == 2) v=20;
if (comboBox4->SelectedIndex == 3) v=30;

n=(mk-ma)/inter;
dataGridView1->RowCount=n+1;

for(i=0;i<=n;i=i+1)
{
no=i+1;
dataGridView1->Rows[i]->Cells[0]->Value=no;
x=ma+(i*inter);
dataGridView1->Rows[i]->Cells[1]->Value=x;
ek=0.5*x*v*v;
dataGridView1->Rows[i]->Cells[2]->Value=ek;
ep=x*g*h;
dataGridView1->Rows[i]->Cells[3]->Value=ep;
em=ep+ek;
dataGridView1->Rows[i]->Cells[4]->Value=em;
}

pg. 36
}
}

19. Program Tabel Konversi Temperatur

Berikut Program Visual nya :

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)


{
comboBox1->SelectedIndex=-1;
comboBox2->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;
dataGridView1->RowCount=1;
dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
dataGridView1->Rows[0]->Cells[3]->Value="";
dataGridView1->Rows[0]->Cells[4]->Value="";
pg. 37
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int i,n;
float Ra,Rk,intv,R,C,F,K,no;

if (comboBox1->SelectedIndex == -1)
MessageBox::Show("Input R awal !!!");
else if (comboBox2->SelectedIndex == -1)
MessageBox::Show("Input R akhir !!!");
else if (radioButton1->Checked==false&&radioButton2-
>Checked==false&&radioButton3->Checked==false&&radioButton4->Checked==false)
MessageBox::Show("Input interval!");
else
{

if (comboBox1->SelectedIndex == 1) Ra=0;
if (comboBox1->SelectedIndex == 2) Ra=30;
if (comboBox1->SelectedIndex == 3) Ra=60;

if (comboBox2->SelectedIndex == 1) Rk=50;
if (comboBox2->SelectedIndex == 2) Rk=80;
if (comboBox2->SelectedIndex == 3) Rk=100;

if (radioButton1->Checked) intv=1;
if (radioButton2->Checked) intv=2;
if (radioButton3->Checked) intv=5;
if (radioButton4->Checked) intv=10;

n=(Rk-Ra)/intv;

dataGridView1->RowCount=n+1;

for(i=0;i<=n;i++)
{
no=i+1;
R=Ra+(i*intv);
C=(R*5/4);
F=(R*9/4)+32;
K=(R*5/4)+273;
dataGridView1->Rows[i]->Cells[0]->Value=no;
dataGridView1->Rows[i]->Cells[1]->Value=R;
dataGridView1->Rows[i]->Cells[2]->Value=C;
dataGridView1->Rows[i]->Cells[3]->Value=F;
dataGridView1->Rows[i]->Cells[4]->Value=K;
}
}
}

20. Program Tabel Sudut

pg. 38
Berikut Program Visual nya :

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)


{
Close();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
listBox1->SelectedIndex=-1;
listBox2->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;

dataGridView1->RowCount=1;
dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
dataGridView1->Rows[0]->Cells[3]->Value="";
dataGridView1->Rows[0]->Cells[4]->Value="";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{

pg. 39
int i,n;
float s,c,t,saw,sak,intv,sdt,no;

//Memasukan Input yang ada pada listBox 1


if(listBox1->SelectedIndex==1)saw=0;
if(listBox1->SelectedIndex==2)saw=90;
if(listBox1->SelectedIndex==3)saw=180;
//Memasukan Input yang ada pada listBox 2
if(listBox2->SelectedIndex==1)sak=90;
if(listBox2->SelectedIndex==2)sak=270;
if(listBox2->SelectedIndex==3)sak=360;
//Memasukan Input yang ada pada groupBox 1
if (radioButton1->Checked) intv=5;
if (radioButton2->Checked) intv=10;
if (radioButton3->Checked) intv=30;
if (radioButton4->Checked) intv=90;

if(listBox1->SelectedIndex==-1) //Apabila
mengosongkan listbox 1
MessageBox::Show("Input Sudut Awal !!");
else if(listBox2->SelectedIndex==-1)
//Apabila mengosongkan listbox 2
MessageBox::Show("Input Sudut Akhir !!");
else if (radioButton1->Checked==false&&radioButton2-
>Checked==false&&radioButton3->Checked==false&&radioButton4->Checked==false)
//Apabila mengosongkan pada input interval
MessageBox::Show("Input Interval !!");
else // Jika dimasukan makan akan muncul rumus seperti
dibawah
{
n=(sak-saw)/intv;
dataGridView1->RowCount=n+1;

for(i=0;i<=n;i=i++)
{
no=i+1;
sdt=saw+(i*intv);
s=sin(sdt/57.2958);
c=cos(sdt/57.2958);
t=tan(sdt/57.2958);

dataGridView1->Rows[i]->Cells[0]->Value=no;
dataGridView1->Rows[i]->Cells[1]->Value=sdt;
if(sdt==180)
dataGridView1->Rows[i]->Cells[3]->Value="0";
else if(sdt==360)
dataGridView1->Rows[i]->Cells[3]->Value="0";
else
dataGridView1->Rows[i]->Cells[3]->Value=s;
if(sdt==90)
dataGridView1->Rows[i]->Cells[4]->Value="0";
else if(sdt==270)
dataGridView1->Rows[i]->Cells[4]->Value="0";
else
dataGridView1->Rows[i]->Cells[4]->Value=c;

pg. 40
if(sdt==90)
//ada perlakuan khusus maka menggunakan if dan else if
dataGridView1->Rows[i]->Cells[2]->Value="inf";
else if(sdt==180)
dataGridView1->Rows[i]->Cells[2]->Value="0";
else if(sdt==360)
dataGridView1->Rows[i]->Cells[2]->Value="0";
else if (sdt==270)
dataGridView1->Rows[i]->Cells[2]->Value="inf";
else
dataGridView1->Rows[i]->Cells[2]->Value=t;
}
}
}

21. Program Tabel GLBB

Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

pg. 41
{
float no,vtaw,vtakh,t,vo,i,n,vt,a,s,status;

if (comboBox1->SelectedIndex == 1) vtaw=100;
if (comboBox1->SelectedIndex == 2) vtaw=200;
if (comboBox1->SelectedIndex == 3) vtaw=300;

if (comboBox2->SelectedIndex == 1) vtakh=400;
if (comboBox2->SelectedIndex == 2) vtakh=500;
if (comboBox2->SelectedIndex == 3) vtakh=600;

if (listBox1->SelectedIndex == 1) vo=150;
if (listBox1->SelectedIndex == 2) vo=200;
if (listBox1->SelectedIndex == 3) vo=300;

if (radioButton1->Checked) t=5;
if (radioButton2->Checked) t=10;
if (radioButton3->Checked) t=15;
if (radioButton4->Checked) t=20;

if (comboBox1->SelectedIndex ==-1||comboBox1-
>SelectedIndex ==0)
MessageBox::Show("Input Vt awal !!");
else if (comboBox2->SelectedIndex ==-1||comboBox2-
>SelectedIndex ==0)
MessageBox::Show("Input Vt Akhir !!");
else if (listBox1->SelectedIndex ==-1||listBox1-
>SelectedIndex ==0)
MessageBox::Show("Input Vo !!");
else if (t==0)
MessageBox::Show("Input Waktu (t) !!");
else

{
n=(vtakh-vtaw)/5;

dataGridView1->RowCount=n+1;

for(i=0;i<=n;i++)
{
no=i+1;
vt=vtaw+(i*5);
a=(vt-vo)/t;
s=(vo*t)+(a*t*t)/2;

dataGridView1->Rows[i]->Cells[0]->Value=no;
dataGridView1->Rows[i]->Cells[1]->Value=vt;
dataGridView1->Rows[i]->Cells[2]->Value=a;
dataGridView1->Rows[i]->Cells[3]->Value=s;

if (a>0)
dataGridView1->Rows[i]->Cells[4]->Value="Dipercepat";
else if (a<0)

pg. 42
dataGridView1->Rows[i]->Cells[4]->Value="Diperlambat";
else
dataGridView1->Rows[i]->Cells[4]->Value="Konstan";
}
}

;}

;
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
comboBox1->SelectedIndex=-1;
comboBox2->SelectedIndex=-1;
listBox1->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;

dataGridView1->RowCount=1;
dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
dataGridView1->Rows[0]->Cells[3]->Value="";
dataGridView1->Rows[0]->Cells[4]->Value="";
}

22. Program Konversi Satuan

pg. 43
Berikut Program Visual nya :

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)


{
comboBox1->SelectedIndex =-1;
groupBox1->Text="Input";
Column1->HeaderText="No";
Column2->HeaderText="Input";
Column3->HeaderText="Out";
Column4->HeaderText="Out";
radioButton1->Checked=false;
radioButton2->Checked=false;

dataGridView1->RowCount=1;
dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
dataGridView1->Rows[0]->Cells[3]->Value="";
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender,
System::EventArgs^ e)
{
if (comboBox1->SelectedIndex == 0)
{
groupBox1->Text="Input mm Akhir";
Column2->HeaderText="mm";
Column3->HeaderText="cm";
Column4->HeaderText="dm";
}
if (comboBox1->SelectedIndex == 1)
{
groupBox1->Text="Input cm Akhir";
Column2->HeaderText="cm";
Column3->HeaderText="dm";
Column4->HeaderText="mm";
}
if (comboBox1->SelectedIndex == 2)
{
groupBox1->Text="Input dm Akhir";
Column2->HeaderText="dm";
Column3->HeaderText="mm";
Column4->HeaderText="cm";
}
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int i,n;
float no,mm,cm,dm,x;

if (comboBox1->SelectedIndex == -1)
MessageBox::Show("Input Satuan !!!");

pg. 44
else if (radioButton1->Checked == false&&radioButton2-
>Checked == false)
MessageBox::Show("Input Diisi !!!");
else
{
if (radioButton1->Checked) x=10;
if (radioButton2->Checked) x=20;

n=x/5;

dataGridView1->RowCount=n+1;

for(i=0;i<=n;i=i+1)
{
no=i+1;

if (comboBox1->SelectedIndex == 0)
{
mm=(i*5);
cm=mm/10;
dm=mm/100;

dataGridView1->Rows[i]->Cells[0]->Value=no;
dataGridView1->Rows[i]->Cells[1]->Value=mm;
dataGridView1->Rows[i]->Cells[2]->Value=cm;
dataGridView1->Rows[i]->Cells[3]->Value=dm;
}
if (comboBox1->SelectedIndex == 1)
{
cm=x-(i*5);
dm=cm/10;
mm=cm*10;

dataGridView1->Rows[i]->Cells[0]->Value=no;
dataGridView1->Rows[i]->Cells[1]->Value=cm;
dataGridView1->Rows[i]->Cells[2]->Value=dm;
dataGridView1->Rows[i]->Cells[3]->Value=mm;
}
if (comboBox1->SelectedIndex == 2)
{
dm=x-(i*5);
mm=dm*100;
cm=dm*10;

dataGridView1->Rows[i]->Cells[0]->Value=no;
dataGridView1->Rows[i]->Cells[1]->Value=dm;
dataGridView1->Rows[i]->Cells[2]->Value=mm;
dataGridView1->Rows[i]->Cells[3]->Value=cm;
}
}
}
}

pg. 45
PR
Ari Reza Koswara
Nim : 10872

1. Program Menghitung Tegangan

Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()

{
float F,A,tegangan;

printf("Mekanika Struktur_Menghitung Tegangan\n");


printf("Dibuat oleh Ari Reza K no.nim 10872\n");
printf("=====================================\n");
printf("\nMasukkan nilai Gaya <F> = ");scanf("%f",&F);
printf("\nMasukkan nilai Luas Penampang <A> = ");scanf("%f",&A);
tegangan=F/A;

pg. 46
printf("\nJadi tegangannya adalah = %.2f N/mm^2",tegangan);

if (tegangan>0)
{
printf("\nDisebut tegangan tarik karena bernilai positif");
}
if (tegangan<0)
{
printf("\nDisebut tegangan tekan karena bernilai negatif");
}

getch();
}

2. Program Menghitung Gaya dan Percepatan

Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()

pg. 47
float F,m,a;
int menu;

printf("\nFisika_menghitung gaya dan percepatan\n");


printf("Dibuat oleh Ari Reza K no nim 10872");
printf("\n=====================================\n");

printf("\n1.Gaya\n");
printf("2.Percepatan\n");
printf("\nPilih menu (1/2) = ");scanf("%d",&menu);

if (menu==1)
{printf("\nMenghitung nilai Gaya");
printf("\nMasukkan nilai Massa <kg> = ");scanf("%f",&m);
printf("Masukkan nilai Percepatan <m/s^2> = ");scanf("%f",&a);
F=m*a;
printf("Jadi nilai Gaya tersebut adalah = %.1f Newton\n",F);
}

else if (menu==2)
{printf("\nMenghitung nilai Percepatan");
printf("\nMasukkan nilai Gaya <F> = ");scanf("%f",&F);
printf("Masukkan nilai Massa <m> = ");scanf("%f",&m);
a=F/m;
printf("Jadi nilai percepatan tersebut adalah = %.1f m/s^2\n",a);
}

else
{printf("\nERROR CODE X00000e9");
}

getch();
}

3. Program Hitung Luas Permukaan

pg. 48
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>
#define phi 3.14

void main ()
{
float r,p,l,a,t,X,Y,Z;
int menu;

printf(" Program Hitung Luas Permukaan\n");


printf(" Oleh Ari Reza Koswara Nim:10872");
printf(" \n ============================================\n\n");

printf(" Pilih Menu \n");


printf(" \n 1.Luas Lingkaran \n");
printf(" 2.Luas Persegi Panjang \n");
printf(" 3.Luas Jajaran Genjang \n");

printf(" \n silahkan pilih menu = ");scanf("%d",&menu);

switch (menu)
{
case 1 :
pg. 49
printf(" \n masukan jari-jarinya (m) : "); scanf("%f",&r);
X=phi*r*r;
printf(" \n Jadi, luas Lingkaran adalah = %.2f m^2",X);
break;

case 2 :
printf(" \n masukan panjangnya (m) : "); scanf("%f",&p);
printf(" \n masukan lebarnya (m) : "); scanf("%f",&l);
Y=p*l;
printf(" \n Jadi, luas persegi panjang adalah = %.2f m^2",Y);
break;

case 3 :
printf(" \n masukan alasnya (m) : "); scanf("%f",&a);
printf(" \n masukan tinggi (m) : "); scanf("%f",&t);
Z=a*t;
printf(" \n Jadi, luas jajaran genjang adalah = %.2f m^2",Z);
break;

default :
printf(" \n ERORRRRR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}

getch();
}

4. Program Hitung Volume Bangun Ruang

Berikut Program Console nya :

pg. 50
#include <stdio.h>
#include <conio.h>
#include <math.h>
#define phi 3.14

void main ()
{
float R,p,l,t,r,T,A,B,C;
int menu;

printf(" Program Hitung Volume Bangun Ruang\n");


printf(" Oleh Ari Reza Koswara Nim:10872");
printf(" \n ============================================\n\n");

printf(" Pilih Menu \n");


printf(" \n 1.Volume Kubus \n");
printf(" 2.Volume Balok \n");
printf(" 3.Volume Tabung \n");

printf(" \n silahkan pilih menu = ");scanf("%d",&menu);

switch (menu)
{
case 1 :
printf(" \n Masukkan panjang rusuknya (m) : "); scanf("%f",&R);
A=R*R*R;
printf(" \n Jadi, volume kubus tersebut adalah = %.2f m^3",A);
break;

case 2 :
printf(" \n Masukkan panjang nya (m) : "); scanf("%f",&p);
printf(" \n Masukkan lebar nya (m) : "); scanf("%f",&l);
printf(" \n Masukkan tinggi nya (m) : "); scanf("%f",&t);
B=p*l*t;
printf(" \n Jadi, volume balok tersebut adalah = %.2f m^3",B);
break;

case 3 :
printf(" \n Masukkan jari-jarinya (m) : "); scanf("%f",&r);
printf(" \n Masukkan tinggi nya (m) : "); scanf("%f",&T);
C=phi*r*r*T;
printf(" \n Jadi, volume tabung tersebut adalah = %.2f m^3",C);
break;

default :
printf(" \n ERRORRRRRRRRRRRRRR!!!!!!!!!!!!!!!!!!!!");
}

getch();
}

5. Program Energi Potensial

pg. 51
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()
{
float m,g,h0,ht,inter,h,Ep;
int n,i;

printf(" Program Energi Potensial\n");


printf(" Oleh : Ari Reza (02)\n");
printf(" ===============================\n\n");

printf(" Masukkan massa <kg> = ");scanf("%f",&m);


printf(" Masukkan Ketinggian Awal = ");scanf("%f",&h0);
printf(" Masukkan Ketinggian Akhir = ");scanf("%f",&ht);
printf(" Masukkan Interval = ");scanf("%f",&inter);
printf("\n Tabel Energi ");
printf("\n =========================================");
printf("\n | No | h | Ep |");
printf("\n =========================================");

n=(ht-h0)/inter;
g=10;

for (i=0;i<=n;i=i+1)
pg. 52
{
h=h0+(i*inter);
Ep=m*g*h;
printf("\n | %5d | %8.1f | %8.1f |",i+1,h,Ep);
}
printf("\n ==========================================");

getch();
}

6. Program Tabel Kecepatan Awal

Berikut Program Console nya :

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
float sekon,a,jarak,VT,VoAW,VoAK,Vnol;
int i,n,inter;

printf(" Program Tabel Kecepatan Awal\n");


printf(" Oleh : Ari Reza K \n");
printf(" ================================\n\n");

pg. 53
printf(" Input waktu yang diinginkan <t> = ");scanf("%f",&sekon);

printf(" Input Vt <m/s> = ");scanf("%f",&VT);

printf(" Input Vo Awal = ");scanf("%f",&VoAW);

printf(" Input Vo Akhir = ");scanf("%f",&VoAK);

printf(" Masukkan Interval = ");scanf("%d",&inter);

printf("\n Tabel Kecepatan Awal ");


printf("\n ====================================================================");
printf("\n | No | Vo | jarak | a | Status |");
printf("\n ====================================================================");

n=(VoAK-VoAW)/inter;

for(i=0;i<=n;i=i+1)
{
Vnol=VoAW+(i*inter);
a=(VT-Vnol)/sekon;
jarak=(Vnol*sekon)+(0.5*a*sekon*sekon);

if(a>0)
printf("\n | %6d | %6.2f | %6.2f | %6.2f | Dipercepat
|",i+1,Vnol,jarak,a);
else if(a<0)
printf("\n | %6d | %6.2f | %6.2f | %6.2f | Diperlambat
|",i+1,Vnol,jarak,a);
else
printf("\n | %6d | %6.2f | %6.2f | %6.2f | Konstan
|",i+1,Vnol,jarak,a);
}
printf("\n ====================================================================");

getch();
}

7. Program Volume Silinder

pg. 54
Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {


float r,t,phi,hasil;

if (listBox1->SelectedIndex == 1) phi=3.14;
if (listBox1->SelectedIndex == 2) phi=22/7;

if (comboBox1->SelectedIndex == 0) r=5;
if (comboBox1->SelectedIndex == 1) r=10;
if (comboBox1->SelectedIndex == 2) r=15;
if (comboBox1->SelectedIndex == 3) r=20;
if (comboBox1->SelectedIndex == 4) r=25;
if (comboBox1->SelectedIndex == 5) r=30;

if (radioButton1->Checked) t=1;
if (radioButton2->Checked) t=3;
if (radioButton3->Checked) t=5;
if (radioButton4->Checked) t=7;
if (radioButton5->Checked) t=9;
if (radioButton6->Checked) t=11;

if (r==0)
{MessageBox::Show("Input jari-jari tidak boleh kosong !!");
}
else if (t==0)
{MessageBox::Show("Input tinggi tabung tidak boleh kosong
!!");
}
else if (phi==0)
{MessageBox::Show("Input phi tidak boleh kosong !!");
}

pg. 55
else
{hasil=phi*r*r*t;
textBox1->Text = Convert::ToString(hasil);
}

}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

Close();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

comboBox1->SelectedIndex=-1;
listBox1->SelectedIndex=-1;
textBox1->Text="";
radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;
radioButton5->Checked=false;
radioButton6->Checked=false;

8. Program Mencari Nilai Diskriminan

Berikut Program Visual nya :

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)


{
comboBox1->SelectedIndex=-1;
comboBox2->SelectedIndex=-1;

pg. 56
comboBox3->SelectedIndex=-1;
label5->Text="xxxx";
label7->Text="xxxx";
label8->Text="xxxx";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
float a,b,c,D,status;

if (comboBox1->SelectedIndex == 1) a=-3;
if (comboBox1->SelectedIndex == 2) a=-2;
if (comboBox1->SelectedIndex == 3) a=-1;
if (comboBox1->SelectedIndex == 4) a=1;
if (comboBox1->SelectedIndex == 5) a=2;
if (comboBox1->SelectedIndex == 6) a=3;
if (comboBox1->SelectedIndex == 7) a=4;

if (comboBox2->SelectedIndex == 1) b=1;
if (comboBox2->SelectedIndex == 2) b=2;
if (comboBox2->SelectedIndex == 3) b=3;
if (comboBox2->SelectedIndex == 4) b=4;
if (comboBox2->SelectedIndex == 5) b=5;
if (comboBox2->SelectedIndex == 6) b=6;
if (comboBox2->SelectedIndex == 7) b=7;

if (comboBox3->SelectedIndex == 1) c=1;
if (comboBox3->SelectedIndex == 2) c=2;
if (comboBox3->SelectedIndex == 3) c=3;
if (comboBox3->SelectedIndex == 4) c=4;
if (comboBox3->SelectedIndex == 5) c=5;
if (comboBox3->SelectedIndex == 6) c=6;
if (comboBox3->SelectedIndex == 7) c=7;

if (a==0)
MessageBox::Show("Input a !!");
else if (b==0)
MessageBox::Show("Input b !!");
else if (c==0)
MessageBox::Show("Input c !!");
else
{
D=(b*b)-4*a*c;
label5->Text = Convert::ToString(D);

if (a>0)
label7->Text = "Terbuka ke atas";
if (a<0)
label7->Text = "Terbuka ke bawah";
if (D>0)
label8->Text = "Memotong sb x di dua titik";
if (D<0)
label8->Text = "Tidak mengenai sumbu x";
if (D==0)
label8->Text = "Menyinggung sb x di satu titik";

pg. 57
}

9. Program Speed Converter

Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)


{
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
float KPH,KPS,MPS;

if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text=="")


MessageBox::Show("Input Tidak Boleh Kosong !!!");
if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text!="")
MessageBox::Show("Input Tidak Boleh Ketiganya !!!");
if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text=="")
MessageBox::Show("Input Tidak Boleh Keduanya !!!");
if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text!="")
MessageBox::Show("Input Tidak Boleh Keduanya !!!");
if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text!="")
MessageBox::Show("Input Tidak Boleh Keduanya !!!");

pg. 58
if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text=="")
{
KPH=Convert::ToDouble(textBox1->Text);
KPS=KPH/3600;
MPS=(KPH*1000)/3600;
textBox2->Text = Convert::ToString(KPS);
textBox3->Text = Convert::ToString(MPS);
}
if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text=="")
{
KPS=Convert::ToDouble(textBox2->Text);
KPH=KPS*3600;
MPS=KPS*1000;
textBox1->Text = Convert::ToString(KPH);
textBox3->Text = Convert::ToString(MPS);
}
if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text!="")
{
MPS=Convert::ToDouble(textBox3->Text);
KPH=(MPS*3600)/1000;
KPS=MPS/1000;
textBox1->Text = Convert::ToString(KPH);
textBox2->Text = Convert::ToString(KPS);
}
}

10. Program Konstanta Pegas

Berikut Program Visual nya :

pg. 59
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
float K,F,X;

if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text=="")


MessageBox::Show("Input Tidak Boleh Kosong !!!");
if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text!="")
MessageBox::Show("Input Tidak Boleh Tiga !!!");
if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text=="")
MessageBox::Show("Input F atau X !!!");
if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text=="")
MessageBox::Show("Input K atau X !!!");
if(textBox1->Text=="" && textBox2->Text=="" && textBox3->Text!="")
MessageBox::Show("Input K atau F !!!");

if(textBox1->Text!="" && textBox2->Text!="" && textBox3->Text=="")


{
K=Convert::ToDouble(textBox1->Text);
F=Convert::ToDouble(textBox2->Text);
X=F/K;
textBox3->Text = Convert::ToString(X);
}
if(textBox1->Text!="" && textBox2->Text=="" && textBox3->Text!="")
{
K=Convert::ToDouble(textBox1->Text);
X=Convert::ToDouble(textBox3->Text);
F=K*X;
textBox2->Text = Convert::ToString(F);
}
if(textBox1->Text=="" && textBox2->Text!="" && textBox3->Text!="")
{
F=Convert::ToDouble(textBox2->Text);
X=Convert::ToDouble(textBox3->Text);
K=F/X;
textBox1->Text = Convert::ToString(K);
}
}

11. Program Tabel Deret Aritmatika

pg. 60
Berikut Program Visual nya :

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)


{
listBox1->SelectedIndex=-1;
listBox2->SelectedIndex=-1;
listBox3->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
dataGridView1->RowCount=1;
dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int i,n;
float a,a1,a2,EN,no,Un,b;

if (listBox1->SelectedIndex == 1) a1=10;
if (listBox1->SelectedIndex == 2) a1=15;
if (listBox1->SelectedIndex == 3) a1=20;

if (listBox2->SelectedIndex == 1) a2=30;
if (listBox2->SelectedIndex == 2) a2=35;
if (listBox2->SelectedIndex == 3) a2=40;

if (listBox3->SelectedIndex == 1) b=2;

pg. 61
if (listBox3->SelectedIndex == 2) b=3;
if (listBox3->SelectedIndex == 3) b=4;

if (radioButton1->Checked) EN=10;
if (radioButton2->Checked) EN=12;

if (listBox1->SelectedIndex ==-1||listBox1->SelectedIndex
==0)
MessageBox::Show("Input Suku Pertama Awal !!");
else if(listBox2->SelectedIndex ==-1||listBox2->SelectedIndex ==0)
MessageBox::Show("Input Suku Pertama Akhir !!");
else if (radioButton1->Checked==false&&radioButton2-
>Checked==false)
MessageBox::Show("Input ke-n nya !!");
else if(listBox3->SelectedIndex ==-1||listBox3->SelectedIndex ==0)
MessageBox::Show("Input Beda !!");
else
{
n=(a2-a1)/5;
dataGridView1->RowCount=n+1;

for(i=0;i<=n;i++)
{
no=i+1;
a=a1+(i*5);
Un=a+(EN-1)*b;

dataGridView1->Rows[i]->Cells[0]->Value=no;
dataGridView1->Rows[i]->Cells[1]->Value=a;
dataGridView1->Rows[i]->Cells[2]->Value=Un;
}
}
}

12. Program Tabel Cutting Speed

pg. 62
Berikut Program Visual nya :

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)


{
listBox1->SelectedIndex=-1;
listBox2->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
dataGridView1->RowCount=1;
dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
dataGridView1->Rows[0]->Cells[3]->Value="";
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int i,n;
float d,d1,d2,CS,bahan,EN,no;

if (listBox1->SelectedIndex == 1) d1=100;
if (listBox1->SelectedIndex == 2) d1=200;
if (listBox1->SelectedIndex == 3) d1=300;

if (listBox2->SelectedIndex == 1) d2=400;
if (listBox2->SelectedIndex == 2) d2=500;
if (listBox2->SelectedIndex == 3) d2=600;

if (radioButton1->Checked) EN=100;

pg. 63
if (radioButton2->Checked) EN=200;

if (listBox1->SelectedIndex ==-1||listBox1->SelectedIndex ==0)


MessageBox::Show("Input d1 !!");
else if(listBox2->SelectedIndex ==-1||listBox1->SelectedIndex ==0)
MessageBox::Show("Input d2 !!");
else if (radioButton1->Checked==false&&radioButton2-
>Checked==false)
MessageBox::Show("Input Kecepatan Putar !!");
else
{
n=(d2-d1)/20;
dataGridView1->RowCount=n+1;

for(i=0;i<=n;i++)
{
no=i+1;
d=d1+(i*20);
CS=(3.14*d*EN)/1000;

dataGridView1->Rows[i]->Cells[0]->Value=no;
dataGridView1->Rows[i]->Cells[1]->Value=d;
dataGridView1->Rows[i]->Cells[2]->Value=CS;

if (CS>30 && CS<90)


dataGridView1->Rows[i]->Cells[3]->Value="Baja Mesin";
else if (CS>90 && CS<150)
dataGridView1->Rows[i]->Cells[3]->Value="Baja
Perkakas";
else if (CS>150 && CS<210)
dataGridView1->Rows[i]->Cells[3]->Value="Besi Tuang";
else if (CS>210 && CS<270)
dataGridView1->Rows[i]->Cells[3]->Value="Besi
Perunggu";
else
dataGridView1->Rows[i]->Cells[3]->Value="Alumunium";
}
}
}

pg. 64
PR
Gatot Yudhanto
Nim : 12283

1. Program Menentukan Kekuatan Benda

Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()

{
float P,F,A;

printf("Menentukan Kekuatan Benda\n");


printf("Oleh: Gatot Y NIM:12283\n");
printf("========================\n\n");

pg. 65
printf("Masukkan Beban (N)=");
scanf("%f",&F);
printf("Masukkan Luas Permukaan (mm^2)=");
scanf("%f",&A);

P=F/A;

printf("\n\nBesarnya Tegangan adalah=%.1f N/mm^2\n" ,P);

if(P>=100)
printf("Benda Patah");

if(P<100)
printf("Benda Tidak Patah");

getch();

2. Program Matematika

pg. 66
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>

void main ()
{

float LP,V,K,p,l,t;
int kode;
printf("Matematika\n");
printf("Nama=Gatot \nNim= 12283\n");
printf(".................. \n\n");

printf("Pilihan Kode\n");
printf("1. Menentukan Luas Permukaan Balok\n");
printf("2. Menentukan Volune Balok \n");
printf("3. Menentukan Keliling Balok \n\n");

printf("Masukkan kode 1-3 sesuai yang diinginkan= ");scanf("%d",&kode);

if(kode==1)
{ printf("Luas Permukaan Balok\n");
printf("\nMasukkan nilai p= ");
scanf("%f",&p);
printf("\nMasukkan nilai l= ");
scanf("%f",&l);
printf("\nMasukkan nilai t= ");
scanf("%f",&t);
LP= 2*((p*l)+(p*t)+(l*t));
printf("Hasil Luas Permukaan Balok= %.2f",LP);

}
else if(kode==2)
{ printf("Volume Balok\n");
printf("\nMasukkan nilai p= ");
scanf("%f",&p);
printf("\nMasukkan nilai l= ");
scanf("%f",&l);
printf("\nMasukkan nilai t= ");
scanf("%f",&t);
V=p*l*t;
printf("Hasil Volume Balok= %.2f",V);
}
else if(kode==3)
{ printf("Keliling Balok\n");
printf("\nMasukkan nilai p= ");
scanf("%f",&p);
printf("\nMasukkan nilai l= ");
scanf("%f",&l);
printf("\nMasukkan nilai t= ");
scanf("%f",&t);

pg. 67
K=4*(p+l+t);
printf("Hasil Keliling Balok= %.2f",K);
}
else
printf("Kode Salah");
getch();
}

3. Program Gerak Jatuh Bebas

Berikut Program Console nya :

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
float h,v,t,v0;
int menu,g;
g=10;

printf("Menghitung Gerak Jatuh Bebas\n");


printf("oleh : Gatot yudhanto (19)\n");

pg. 68
printf("====================================\n\n");
printf("Pilihan Menu :\n1. Menghitung Kecepatan Di Permukaan Tanah (v)\n2.
Menghitung Lama Benda Sampai Tanah (t)");
printf("\nPilih Menu (1 atau 2) : ");scanf("%d",&menu);

if(menu==1)
{
printf("\nMenghitung Kecepatan Di Permukaan Tanah (v)\n");
printf("-------------------------------------------\n");
printf("Masukkan Tinggi Dari Permukaan Tanah (h) : ");scanf("%f",&h);
v0=2*g*h;
v=sqrt(v0);
printf("Hasilnya adalah : %.3f", v);
}

else if(menu==2)
{
printf("\nMenghitung Lama Benda Sampai Tanah (t)\n");
printf("------------------------------------------\n");
printf("Masukkan Tinggi Dari Permukaan Tanah (h) : ");scanf("%f",&h);
t=sqrt((2*h/g));
printf("Hasilnya adalah : %.3f", t);
}

else
printf("\nNomor Salah");

getch();
}

4. Program Menghitung Kecepatan Gerak Lurus

pg. 69
Berikut Program Console nya :

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
float v,s,t,a,vt,v0;
int menu;

printf("Program Menghitung Kecepatan Gerak Lurus\n");


printf("oleh : Gatot yudhanto (19)\n");
printf("========================================\n\n");
printf("Pilihan Menu :\n1. Gerak Lurus Beraturan (GLB)\n2. Gerak Lurus Berubah
Beraturan (GLBB)");
printf("\nPilih Menu (1 atau 2) : ");scanf("%d",&menu);

switch(menu)
{
case 1:
printf("\nMenghitung Kecepatan (v) GLB\n");
printf("--------------------------------\n");
printf("Masukkan Jarak (s) : ");scanf("%f",&s);
printf("Masukkan Waktu (t) : ");scanf("%f",&t);
v=s/t;
printf("Hasilnya adalah : %.3f",v);

pg. 70
break;

case 2:
printf("\nMenghitung Kecepatan Akhir (vt) GLBB\n");
printf("----------------------------------------\n");
printf("Masukkan Kecepatan Awal (v0) : ");scanf("%f",&v0);
printf("Masukkan Waktu (t) : ");scanf("%f",&t);
printf("Masukkan Percepatan (a) : ");scanf("%f",&a);
vt=a*t+v0;
printf("Hasilnya adalah : %.3f",vt);
break;

default:
printf("\nInput Tidak Dikenal");
}

getch();
}

5. Program Tabel Volume dan Luas dari Kubus

Berikut Program Console nya :


pg. 71
#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
float da,dk,inter,dt,V,L;
int i,n;

printf("Tabel Volume dan Luas Bangun Kubus\n");


printf("oleh :Gatot Yudhanto (19) \nNIM:12283");
printf("\n========================================\n\n");

printf("Masukkan Data Awal = ");scanf("%f",&da);


printf("Masukkan Data Akhir = ");scanf("%f",&dk);
printf("Masukkan Interval = ");scanf("%f",&inter);
printf("\n Tabel Volume dan Luas Bangung Kubus ");
printf("\n ===========================");
printf("\n |No | Data | Volume | Luas |");
printf("\n ===========================");

n=(dk-da)/inter;
for(i=0;i<=n;i=i+1)
{
dt=da+(i*inter); V=dt*dt*dt; L=dt*dt*6;
printf("\n |%2d | %6.2f | %6.2f |%6.2f |",i+1,dt,V,L);
}

getch();
}

6. Program Menentukan Usaha

pg. 72
Berikut Program Console nya :

#include <stdio.h>
#include <conio.h>

void main ()
{

int Kode;

printf(" Menentukan Usaha ");


printf("\nOleh : Gatot Y NIM : 12283");
printf("\n=============================");

printf("\n\n\nPilihan Usaha");
printf("\n 1. Searah dengan arah benda");
printf("\n 2. Berlawanan dengan arah benda");
printf("\n 3. Tidak menyebabkan perpindahan");

printf("\n\n\nMasukkan Kode = "); scanf("%d",&Kode);

switch (Kode)

case 1 :
printf("\nUsaha Bernilai POSITIF");
break;

case 2 :
printf("\nUsaha Bernilai NEGATIF");
break;

case 3 :
printf("\nUsaha Bernilai NOL");
break;

default :
printf("\n\nMaaf, Anda Memasukkan Kode Yang Salah");
printf("\n\n Coba Ulangi Lagi");

getch ();

pg. 73
7. Program Garvitasi Vertikal Ke Bawah

Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)


{

float vo,g,t,vt;

if (comboBox1->SelectedIndex == 0) vo=2;
if (comboBox1->SelectedIndex == 1) vo=4;
if (comboBox1->SelectedIndex == 2) vo=6;

if (listBox1->SelectedIndex == 0) t=5;
if (listBox1->SelectedIndex == 1) t=10;
if (listBox1->SelectedIndex == 2) t=15;

if (radioButton1->Checked) g=9.8;
if (radioButton2->Checked) g=10;

pg. 74
if (vo==0)
MessageBox::Show("Masukan vo!!!");
else if (t==0)
MessageBox::Show("Masukan t!!!");
else if (g==0)
MessageBox::Show("Masukan g!!!");
else

{
vt=vo+(t*g);

label5->Text = Convert::ToString(vt);
}
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
comboBox1->SelectedIndex=-1;
listBox1->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;

label5->Text="xxxxx";
}
private: System::Void button2_Click_1(System::Object^ sender, System::EventArgs^ e)
{
comboBox1->SelectedIndex=-1;
listBox1->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
label5->Text="xxxx";
}
private: System::Void button3_Click_1(System::Object^ sender, System::EventArgs^ e)
{
Close();
}

8. Program Melempar Bola Dengan Sudut Teta

pg. 75
Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)


{
float tp,t,h,vo,hb,hm,tt;

if (comboBox1->SelectedIndex == 0) vo=10;
if (comboBox1->SelectedIndex == 1) vo=20;
if (comboBox1->SelectedIndex == 2) vo=30;
if (comboBox1->SelectedIndex == 3) vo=40;
if (listBox1->SelectedIndex == 1) tt=30;
if (listBox1->SelectedIndex == 2) tt=45;
if (listBox1->SelectedIndex == 3) tt=60;
if (listBox1->SelectedIndex == 4) tt=90;

if (radioButton1->Checked) t=1;
if (radioButton2->Checked) t=2;
if (radioButton3->Checked) t=3;
if (radioButton4->Checked) t=4;
if (radioButton5->Checked) t=5;
if (radioButton6->Checked) t=6;
if (radioButton7->Checked) t=7;
if (radioButton8->Checked) t=8;
if (radioButton9->Checked) t=9;

pg. 76
if (comboBox1->SelectedIndex == -1)
MessageBox::Show("Input Vo tidak boleh kosong!!");
else if (listBox1->SelectedIndex == -1)
MessageBox::Show("Input Sudut tidak boleh kosong!!");
else if (t==0)
MessageBox::Show("Input t tidak boleh
kosong!!");
else
{
tp=(vo*(sin(tt/57.2958)))/10;
h=((vo*t*(sin(tt/57.2958)))-(5*t*t));
hm=(vo*vo*(sin(tt/57.2958))*(sin(tt/57.2958)))/20;

{
if(h>0)
label6->Text = Convert::ToString(h);
else if(h<0)
label6->Text = "0";
else
label6->Text = "xxxxx";
}
{
if(t<tp)
label5->Text = "naik";
else if(tp==t)
label5->Text = "puncak";
else if(t>tp)
label5->Text = "turun";
else if(h<0)
label5->Text = "menyentuh tanah";
else

label5->Text = "xxxxx";
}
}

}
private: System::Void button2_Click_1(System::Object^ sender, System::EventArgs^ e)
{
comboBox1->SelectedIndex=-1;
listBox1->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;
radioButton5->Checked=false;
radioButton6->Checked=false;
radioButton7->Checked=false;
radioButton8->Checked=false;
radioButton9->Checked=false;
label5->Text = "xxxxx";
label6->Text = "xxxxx";
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)

pg. 77
{
Close();
}

9. Program Gaya

Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)


{

float f,m,a;
if(textBox1->Text=="" && textBox2->Text=="" && textBox3-
>Text=="")
MessageBox::Show("Input Tidak Boleh Kosong !!!");
if(textBox1->Text!="" && textBox2->Text!="" && textBox3-
>Text!="")
MessageBox::Show("Input Tidak Boleh Semua !!!");
if(textBox1->Text!="" && textBox2->Text=="" && textBox3-
>Text=="")
MessageBox::Show("Input m atau a !!!");
if(textBox1->Text=="" && textBox2->Text!="" && textBox3-
>Text=="")
MessageBox::Show("Input f atau a !!!");

pg. 78
if(textBox1->Text=="" && textBox2->Text=="" && textBox3-
>Text!="")
MessageBox::Show("Input f atau m !!!");
if(textBox1->Text=="" && textBox2->Text!="" && textBox3-
>Text!="")
{
m=Convert::ToDouble(textBox2->Text);
a=Convert::ToDouble(textBox3->Text);
f=a*m;
textBox1->Text = Convert::ToString(f);
}
if(textBox1->Text!="" && textBox2->Text=="" && textBox3-
>Text!="")
{
f=Convert::ToDouble(textBox1->Text);
a=Convert::ToDouble(textBox3->Text);
m=f/a;
textBox2->Text = Convert::ToString(m);
}
if(textBox1->Text!="" && textBox2->Text!="" && textBox3-
>Text=="")
{
f=Convert::ToDouble(textBox1->Text);
m=Convert::ToDouble(textBox2->Text);
a=f/m;
textBox3->Text = Convert::ToString(a);
}

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)


{
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";

}
private: System::Void button2_Click_1(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
}

10. Program Segitiga

pg. 79
Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)


{
float w,f,s;
if(textBox1->Text=="" && textBox2->Text=="" && textBox3-
>Text=="")
MessageBox::Show("Input Tidak Boleh Kosong !!!");
if(textBox1->Text!="" && textBox2->Text!="" && textBox3-
>Text!="")
MessageBox::Show("Input Tidak Boleh Semua !!!");
if(textBox1->Text!="" && textBox2->Text=="" && textBox3-
>Text=="")
MessageBox::Show("Input alas atau tinggi !!!");
if(textBox1->Text=="" && textBox2->Text!="" && textBox3-
>Text=="")
MessageBox::Show("Input Luas atau tinggi !!!");
if(textBox1->Text=="" && textBox2->Text=="" && textBox3-
>Text!="")
MessageBox::Show("Input Luas atau alas !!!");
if(textBox1->Text!="" && textBox2->Text!="" && textBox3-
>Text=="")
{
w=Convert::ToDouble(textBox1->Text);
f=Convert::ToDouble(textBox2->Text);
s=2*w/f;
textBox3->Text = Convert::ToString(s);
}

pg. 80
if(textBox1->Text!="" && textBox2->Text=="" && textBox3-
>Text!="")
{
w=Convert::ToDouble(textBox1->Text);
s=Convert::ToDouble(textBox3->Text);
f=2*w/s;
textBox2->Text = Convert::ToString(f);
}
if(textBox1->Text=="" && textBox2->Text!="" && textBox3-
>Text!="")
{
f=Convert::ToDouble(textBox2->Text);
s=Convert::ToDouble(textBox3->Text);
w=(f*s)/2;
textBox1->Text = Convert::ToString(w);
}

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
}
private: System::Void button3_Click_1(System::Object^ sender, System::EventArgs^ e)
{
Close();
}
private: System::Void button2_Click_1(System::Object^ sender, System::EventArgs^ e)
{
textBox1->Text="";
textBox2->Text="";
textBox3->Text="";
}

11. Program Luas dan Volume Bola

pg. 81
Berikut Program Visual nya :

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)


{
int i,n,No;
float nawr,nakr,intv,lb,vb,r;

if (radioButton9->Checked==false&&radioButton8-
>Checked==false&&radioButton7->Checked==false&&radioButton6-
>Checked==false&&radioButton5->Checked==false&&radioButton4-
>Checked==false&&radioButton3->Checked==false&&radioButton2-
>Checked==false&&radioButton1->Checked==false)
{MessageBox::Show("Pilih jari jari awal ");}
else if(textBox2->Text=="")
{MessageBox::Show("Tentukan jari jari akhir !!!");}
else if (comboBox1->SelectedIndex==-1)
{MessageBox::Show("Interval harus dipilih !!");}
else
{

nakr=Convert::ToDouble(textBox2->Text);

if (radioButton1->Checked) nawr= -3;


if (radioButton2->Checked) nawr= -2;

pg. 82
if (radioButton3->Checked) nawr= -1;
if (radioButton4->Checked) nawr= 0;
if (radioButton5->Checked) nawr= 1;
if (radioButton6->Checked) nawr= 2;
if (radioButton7->Checked) nawr= 3;
if (radioButton8->Checked) nawr= 5;
if (radioButton9->Checked) nawr= 10;

if (comboBox1->SelectedIndex == 0) intv= 1;
if (comboBox1->SelectedIndex == 1) intv= 2;
if (comboBox1->SelectedIndex == 2) intv= 3;
if (comboBox1->SelectedIndex == 3) intv= 4;
if (comboBox1->SelectedIndex == 4) intv= 5;

if (nawr>=nakr)
MessageBox::Show("Jari jari awal < Jari jari
akhir !!");

else
{n=(nakr-nawr)/intv;

dataGridView1->RowCount=n+1;

for (i=0;i<=n;i=i+1)
{
No=(i+1);
r=nawr+(i*intv);
lb=((88*r*r)/7);
vb=((88*r*r)/21);

dataGridView1->Rows[i]->Cells[0]->Value=No;

dataGridView1->Rows[i]->Cells[1]->Value=r;
dataGridView1->Rows[i]->Cells[2]->Value=lb;
dataGridView1->Rows[i]->Cells[3]->Value=vb;

}
}

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
dataGridView1->RowCount=1;

dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
dataGridView1->Rows[0]->Cells[3]->Value="";

radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;

pg. 83
radioButton5->Checked=false;
radioButton6->Checked=false;
radioButton7->Checked=false;
radioButton8->Checked=false;
radioButton9->Checked=false;

comboBox1->SelectedIndex=-1;

textBox2->Text="";

}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
{
Close();
}

12. Program Gradien Garis

Berikut Program Visual nya :

pg. 84
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
int i,n,No;
float nawx,nakx,intvx,nawy,intvy,x,y,m;

if (comboBox1->SelectedIndex==-1)
MessageBox::Show("Input sumbu X awal !!");
else if(comboBox2->SelectedIndex==-1)
MessageBox::Show("Input sumbu X akhir !!!");
else if(radioButton6->Checked==false&&radioButton5-
>Checked==false&&radioButton4->Checked==false&&radioButton3-
>Checked==false&&radioButton2->Checked==false&&radioButton1->Checked==false)
{MessageBox::Show("Input interval sumbu X !!");}
else if (comboBox2->SelectedIndex==-1)
MessageBox::Show("Input sumbu Y awal !!");
else if (listBox1->SelectedIndex ==-1)
MessageBox::Show("Input interval Y !!");
else
{
if (comboBox1->SelectedIndex == 0) nawx= -3;
if (comboBox1->SelectedIndex == 1) nawx= -2;
if (comboBox1->SelectedIndex == 2) nawx= -1;
if (comboBox1->SelectedIndex == 3) nawx= 0;
if (comboBox1->SelectedIndex == 4) nawx= 1;
if (comboBox1->SelectedIndex == 5) nawx= 3;
if (comboBox1->SelectedIndex == 6) nawx= 5;
if (comboBox1->SelectedIndex == 7) nawx= 7;

if (comboBox2->SelectedIndex == 0) nakx= 1;
if (comboBox2->SelectedIndex == 1) nakx= 2;
if (comboBox2->SelectedIndex == 2) nakx= 3;
if (comboBox2->SelectedIndex == 3) nakx= 4;
if (comboBox2->SelectedIndex == 4) nakx= 5;
if (comboBox2->SelectedIndex == 5) nakx= 6;
if (comboBox2->SelectedIndex == 6) nakx= 7;
if (comboBox2->SelectedIndex == 7) nakx= 8;

if (comboBox3->SelectedIndex == 0) nawy= -2;


if (comboBox3->SelectedIndex == 1) nawy= -1;
if (comboBox3->SelectedIndex == 2) nawy= 0;
if (comboBox3->SelectedIndex == 3) nawy= 1;
if (comboBox3->SelectedIndex == 4) nawy= 2;
if (comboBox3->SelectedIndex == 5) nawy= 3;
if (comboBox3->SelectedIndex == 6) nawy= 6;
if (comboBox3->SelectedIndex == 7) nawy= 9;

if (radioButton1->Checked) intvx= 1;
if (radioButton2->Checked) intvx= 2;
if (radioButton3->Checked) intvx= 3;
if (radioButton4->Checked) intvx= 4;
if (radioButton5->Checked) intvx= 5;
if (radioButton6->Checked) intvx= 10;

if (listBox1->SelectedIndex == 1) intvy=2;
if (listBox1->SelectedIndex == 2) intvy=3;

pg. 85
if (listBox1->SelectedIndex == 3) intvy=4;
if (listBox1->SelectedIndex == 4) intvy=5;
if (nawx>nakx)
MessageBox::Show("Nilai X awal harus lebih
besar dari nilai X akhir!!");

if (intvx==intvy)
{ MessageBox::Show("Nilai interval X tidak boleh
sama dengan interval Y !!");

else
{n=(nakx-nawx)/intvx;

dataGridView1->RowCount=n+1;

for (i=0;i<=n;i=i+1)
{
No=(i+1);
dataGridView1->Rows[i]->Cells[0]->Value=No;
x=nawx+(i*intvx);
dataGridView1->Rows[i]->Cells[1]->Value=x;
y=nawy+(i*intvy);
dataGridView1->Rows[i]->Cells[2]->Value=y;
m=x/y;
dataGridView1->Rows[i]->Cells[3]->Value=m;

if (m>0)
dataGridView1->Rows[i]->Cells[4]->Value="gradien
garis positif";
if (m<0)
dataGridView1->Rows[i]->Cells[4]->Value="gradien
garis negatif";
if (m==0)
dataGridView1->Rows[i]->Cells[4]->Value="tidak
memiliki gradien ";

}
}
}
}
private: System::Void button2_Click_1(System::Object^ sender, System::EventArgs^ e)
{
dataGridView1->RowCount=1;

dataGridView1->Rows[0]->Cells[0]->Value="";
dataGridView1->Rows[0]->Cells[1]->Value="";
dataGridView1->Rows[0]->Cells[2]->Value="";
dataGridView1->Rows[0]->Cells[3]->Value="";
dataGridView1->Rows[0]->Cells[4]->Value="";

comboBox1->SelectedIndex=-1;
comboBox2->SelectedIndex=-1;
comboBox3->SelectedIndex=-1;

pg. 86
listBox1->SelectedIndex=-1;
radioButton1->Checked=false;
radioButton2->Checked=false;
radioButton3->Checked=false;
radioButton4->Checked=false;
radioButton5->Checked=false;
radioButton6->Checked=false;
}
private: System::Void button3_Click_1(System::Object^ sender, System::EventArgs^ e)
{
Close();
}

pg. 87

Anda mungkin juga menyukai