Senin, 28 Desember 2015

TUGAS KELOMPOK PERTEMUAN 13

* Buatlah Shortest path problem untuk graph dibawah ini.



> cara penyelesaian SHORTEST PATH PROBLEM 
  - pertama : Melihat proses simpul yang mempunyai awal dan akhir tujuan dari graph.
  - kedua   : mencari jalur tterpendek dari tiap-tiap proses jalur tersebut dengan menghitung
                   panjang tiap-tiap jalur.

Jalur A-B

 . A-B         = 25
 . A-D-B       = 55 + 5 = 60

Jalur terpendek untuk simpul A ke B = 25

Jalur A-C

 . A-B-C      = 25 + 45 = 70
 . A-D-B-C    = 55 + 5 + 45 = 105

Jalur terpendek untuk simpul A ke C = 70

Jalur A-D

 . A-D        = 55
 . A-B-C-D    = 25 + 45 + 35 = 105

Jalur terpendek untuk simpul A ke D = 55

Jalur A-E

 . A-E            = 15
 . A-B-C-D-E      = 25 + 45 + 35 + 20 = 125
 . A-D-E          = 55 + 20 = 75

Jalur terpendek untuk simpul A ke E = 15

HASIL..

TUGAS KELOMPOK PERTEMUAN 12

* Metode greedy

Terdapat mobil angkutan dengan kapasitas muatan=255 kg. seorang petani akan membawa hasil pertaniannya ke kota dengan Barang-barang sebagai berikut :
1. Wortel   20  kg  = Rp. 1 juta
2. Beras    150 kg  = Rp. 2 juta
3. Mangga   100 kg  = Rp. 1.5 juta
4. Sayuran  50  kg  = Rp. 1 juta
5. Bawang   50  kg  = Rp. 1.2 juta

Tentukan Barang yang akan di bawa petani agar optimal.

diketahui w =weight.
                p =profit.
                m =255 kg.

>>By Profit.

W2.x2 + W3.X3 + W5.X5 + W4.X4 + W1.X1 = 255
150.1 + 100.1 + 50.x5 +   0   +  0    = 255
                50.x5                 = 255-250
                   x5                 = 5/50
                   x5                 = 1/10
                                     
   (x1.x2.x3.x4.x5)
Pi=(0 . 1. 1. 0. 1/10)


>>By Weight.


w1.x1 + w5.x5 + w4.x4 + w3.x3 + w2.x2  = 255
20.1  + 50.1  + 100.1 + 100.1 + 150.x2 = 255
                                150.x2 = 255-220
                                150.x2 = 35
                                    x2 = 35/150
                                    x2 = 7/30

   (x1. x2 .x3 .x4 .x5)
wi=(1 .7/30. 1 . 1 . 1)



Minggu, 27 Desember 2015

TUGAS KELOMPOK PERTEMUAN 9

* mencari nilai MAX dan MIN.

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <windows.h>

void judul()
{
cout<<" MENENTUKAN NILAI MAXIMUM DAN MINIMUM"<<endl;
cout<<"++++++++++++++++++++++++++++++++++++++++"<<endl;
}

main()
{
int nilai[10]={55,71,28,14,68,20,33,31,9,12};
int i,n=10,max,min;

cout<<endl;
cout<<" NAMA KELOMPOK"<<endl;
cout<<" 1. FITRI ENDANG LESTARI      [NIM : 11150264]  "<<endl;
cout<<" 2. EVI MONICA GINTING        [NIM : 11150528]  "<<endl;
cout<<" 3. SANDI KURNIAWAN RAMADHAN  [NIM : 11151190]  "<<endl;
cout<<" 4. WILDAN AGUNG MAULANA      [NIM : 11152075]  "<<endl;
cout<<" KELAS  : 11.1B.27 "<<endl;
cout<<" TAHUN AJARAN   : 2015/2016 "<<endl;
cout<<endl;
judul();
cout<<endl;
cout<<" DIKETAHUI NILAI = ";
for (i=0;i<10;i++)
{cout<<nilai[i]<<" ";}
cout<<endl;
max=min=nilai[0];
for(i=0;i<n;)
{
if (nilai[i]>max)
 {max=nilai[i];}
else if (nilai[i]<min)
 {min=nilai[i];}
 i++;
}
cout<<endl;
cout<<" MAXIMUM NILAI DI ATAS = "<<max<<endl;
cout<<endl;
cout<<" MINIMUM NILAI DI ATAS = "<<min<<endl;
getch();
}


* Matrix
Tugas Kelompok (max 5 orang)

Buatlah program dengan menggunakan C++
1. penjumlahan dua buah Matriks
2. Pengurangan dua buah Matriks

ket :
> Masing-masing kelompok dapat memilih salah satu dari
   program di atas.
> listing program & output dicetak.
> Nama, Nim dan Kelas dicetak di listing Program.

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

void judul()
{
cout<<"                **MatriX**                 "<<endl;
cout<<"============================================"<<endl;
}

main()
{
int i,j;
int mat1[5][5];
int mat2[5][5];
int mat3[5][5];

cout<<endl;
cout<<" NAMA KELOMPOK"<<endl;
cout<<" 1. FITRI ENDANG LESTARI      [NIM : 11150264]  "<<endl;
cout<<" 2. EVI MONICA GINTING        [NIM : 11150528]  "<<endl;
cout<<" 3. SANDI KURNIAWAN RAMADHAN  [NIM : 11151190]  "<<endl;
cout<<" 4. WILDAN AGUNG MAULANA      [NIM : 11152075]  "<<endl;
cout<<" KELAS  : 11.1B.27 "<<endl;
cout<<" TAHUN AJARAN   : 2015/2016 "<<endl;
cout<<endl;
judul();
cout<<endl;
for(i=0;i<=1;i++)
{
 for(j=0;j<=1;j++)
 {
 cout<<" Input MATRIX A ke- "<<"["<<i<<"]"<<"["<<j<<"]"<<" : ";
 cin>>mat1[i][j];
 }
}
cout<<endl;
cout<<" MATRIX A "<<endl;
cout<<endl;
for(i=0;i<=1;i++)
{
 for(j=0;j<=1;j++)
 {
  cout<<setiosflags(ios::right)<<setw(4)<<mat1[i][j];
 }
  cout<<endl;
}
// MATRIX B
cout<<endl;
for(i=0;i<=1;i++)
{
 for(j=0;j<=1;j++)
 {
 cout<<" Input MATRIX B ke- "<<"["<<i<<"]"<<"["<<j<<"]"<<" : ";
 cin>>mat2[i][j];
 }
}
cout<<endl;
cout<<" MATRIX B "<<endl;
cout<<endl;
for(i=0;i<=1;i++)
{
 for(j=0;j<=1;j++)
 {
  cout<<setiosflags(ios::right)<<setw(4)<<mat2[i][j];
 }
  cout<<endl;
}
//penjumlahan mat c

cout<<endl;
cout<<" PENJUMLAHAN "<<endl;
cout<<" MATRIX A + B "<<endl;
cout<<endl;
for(i=0;i<=1;i++)
{
 for(j=0;j<=1;j++)
 {
  mat3[i][j]=mat1[i][j]+mat2[i][j];
  cout<<setiosflags(ios::right)<<setw(4)<<mat3[i][j];
 }
  cout<<endl;
}
//pengurangan mat c
cout<<endl;
cout<<" PENGURANGAN "<<endl;
cout<<" MATRIX A - B "<<endl;
cout<<endl;
for(i=0;i<=1;i++)
{
 for(j=0;j<=1;j++)
 {
  mat3[i][j]=mat1[i][j]-mat2[i][j];
  cout<<setiosflags(ios::right)<<setw(4)<<mat3[i][j];
 }
  cout<<endl;
}
getch();
}


TUGAS KELOMPOK PERTEMUAN 5

* Convensi Menggunakan While dari 9 = 3 dan 6 = 2 ..
 
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <windows.h>

main()
{
cout<<endl;
cout<<" NAMA KELOMPOK"<<endl;
cout<<" 1. FITRI ENDANG LESTARI      [NIM : 11150264]  "<<endl;
cout<<" 2. EVI MONICA GINTING        [NIM : 11150528]  "<<endl;
cout<<" 3. SANDI KURNIAWAN RAMADHAN  [NIM : 11151190]  "<<endl;
cout<<" 4. WILDAN AGUNG MAULANA      [NIM : 11152075]  "<<endl;
cout<<" KELAS  : 11.1B.27 "<<endl;
cout<<" TAHUN AJARAN   : 2015/2016 "<<endl;
cout<<endl;
cout<<" CONVERSI MENGGUNAKAN WHILE 9=3 dan 6=2 "<<endl;
cout<<"******************************************"<<endl;
int nilai=9;
do
 {cout<<" "<<nilai;nilai-=3;}
 while(nilai>=0);
cout<<endl;
int angka=6;
do
 {cout<<" "<<angka;angka-=2;}
 while(angka>=0);
getch();
}


* Buatlah Algoritma dan program untuk mentukan toatl pembelian minuman apabila diberlakukan  ketentuan berikut ini :

kode          Jenis minuman         Harga
 1                 MILO                      Rp. 10000
 2                 KOPI                       Rp.   3000
 3                 Teh Manis               Rp.   2500
 4                 Jus                           Rp.  5000
kode minum di inputkan. Apabila total pembelian melebihi Rp. 100.000, maka mendapat potongan sebanyak 15%, jika kurang dari Rp. 100.000 tidak mendapat potongan.

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <windows.h>
#include <math.h>

void judul()
{cout<<" ALGORITMA PEMBELIAN MINUMAN. (slide 5) "<<endl;}

main()
{
char *minuman,ulang,kode,kd;
int harga,total,pot,jumlah,bayar,k,tb;

awal:
clrscr();
cout<<" NAMA KELOMPOK"<<endl;
cout<<" 1. FITRI ENDANG LESTARI      [NIM : 11150264]  "<<endl;
cout<<" 2. EVI MONICA GINTING        [NIM : 11150528]  "<<endl;
cout<<" 3. SANDI KURNIAWAN RAMADHAN  [NIM : 11151190]  "<<endl;
cout<<" 4. WILDAN AGUNG MAULANA      [NIM : 11152075]  "<<endl;
cout<<" KELAS  : 11.1B.27 "<<endl;
cout<<" TAHUN AJARAN   : 2015/2016 "<<endl;
cout<<endl;
judul();
cout<<"**************************************"<<endl;
cout<<endl;
cout<<endl;
cout<<" JENIS MINUMAN "<<endl;
cout<<" 1. MILO        = Rp. 10000"<<endl;
cout<<" 2. KOPI        = Rp.  3000"<<endl;
cout<<" 3. TEH MANIS   = Rp.  2500"<<endl;
cout<<" 4. JUS         = Rp.  5000"<<endl;
cout<<endl;
cout<<endl;
cout<<" INPUT KODE [1/2/3/4] : ",cin>>kode;
if (kode=='1')
 {
  kd='1';
  minuman="MILO";
  harga=10000;
 }
else if (kode=='2')
 {
  kd='2';
  minuman="KOPI";
  harga=3000;
 }
else if (kode=='3')
 {
  kd='3';
  minuman="TEH MANIIS";
  harga=2500;
 }
else if (kode=='4')
 {
  kd='4';
  minuman="JUS";
  harga=5000;
 }
else
 {
 cout<<endl;
  cout<<" KODE INVALID "<<endl;
  cout<<" 0 = ULANGI : "<<endl;
  cout<<" 1 = EXIT   : "<<endl;
    cout<<" MASUKAN PILIHAN [0/1] : ",cin>>ulang;
    if ( ulang=='1' || ulang=='1')
      exit (1 || 1);
    else if ( ulang=='0' || ulang=='0')
      goto awal;

 }
cout<<endl;
cout<<" JUMLAH BELI          : ",cin>>jumlah;
clrscr();
cout<<endl;
judul();
cout<<"**************************************"<<endl;
cout<<endl;
cout<<" KODE         : "<<kd<<endl;
cout<<" MINUMAN      : "<<minuman<<endl;
cout<<" JUMLAH       : "<<jumlah<<endl;
cout<<" HARGA        : Rp. "<<harga<<endl;
total=harga*jumlah;
cout<<" TOTAL        : Rp. "<<total<<endl;
if (total>100000)
 {
 pot=(total*15)/100;
 }
else
 {
 pot=0;
 }
cout<<" DISKON       : Rp. "<<pot<<endl;
tb=total-pot;
cout<<" TOTAL BAYAR  : Rp. "<<tb<<endl;
cout<<"=============================="<<endl;
cout<<" BAYAR        : Rp. ",cin>>bayar;
k=bayar-tb;
cout<<" KEMBALI      : Rp. "<<k<<endl;
cout<<endl;
cout<<endl;
  cout<<" 0 = PESAN LAGI : "<<endl;
  cout<<" 1 = EXIT       : "<<endl;
    cout<<" MASUKAN PILIHAN [0/1] : ",cin>>ulang;
    if ( ulang=='1')
      exit (1 || 1);
    else if ( ulang=='0')
      goto awal;

getch();
}

> program dengan Potongan.





> program tanpa Potongan




* Buatlah Algoritma dan Program untuk Menentukan sisa hasil pembagian antara bilangan yang di masukan dengan billangan pembagi. Apabila sisa baginya=0 maka di cetak tidak ada dan jika ada sisa baginya di tampilkan.

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <windows.h>
#include <math.h>

void judul()
{
 cout<<" MENENTUKAN SISA HASIL BAGI (slide 5) "<<endl;
 cout<<"**************************************"<<endl;
}

main()
{

float nilai,n,hasil;

judul();
cout<<endl;
cout<<" NAMA KELOMPOK"<<endl;
cout<<" 1. FITRI ENDANG LESTARI      [NIM : 11150264]  "<<endl;
cout<<" 2. EVI MONICA GINTING        [NIM : 11150528]  "<<endl;
cout<<" 3. SANDI KURNIAWAN RAMADHAN  [NIM : 11151190]  "<<endl;
cout<<" 4. WILDAN AGUNG MAULANA      [NIM : 11152075]  "<<endl;
cout<<" KELAS  : 11.1B.27 "<<endl;
cout<<" TAHUN AJARAN   : 2015/2016 "<<endl;
cout<<endl;
judul();
cout<<endl;
cout<<" MASUKAN NILAI YANG AKAN DI BAGI : ",cin>>nilai;
cout<<endl;
cout<<" MASUKAN PEMBAGI                 : ",cin>>n;
hasil=nilai/n;
cout<<endl;
cout<<" HASIL PEMBAGIAN = "<<hasil;
cout<<endl;
if(hasil==0)
{cout<<"  HASIL TIDAK ADA "<<endl;}

getch();
}

> program dengan HASIL.


> program tanpa HASIL.


Minggu, 06 Desember 2015

TUGAS KELOMPOK ( PERTEMUAN 4 dan 3 )

Tugas Kelompok (max 5 orang  Pertemuan 3)
membuat program sederhana dengan mengunakan C++
> Menghitung Luas Segiitiga
> Menghitung Luas Persegi Panjang
> Menghitung Luas Bujur Sangkar

 catatan :
 - Pergunakan fungsi cin & cout atau scanf dan printf - Tampilkan NIM, Nama & Kelas Pada prgram  tersebut - Listing program & output di cetak.

JAWABAN :

  • Menghitung luas Segitiga

 #include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main(int argc, char** argv)
{
float luas,alas,tinggi;

cout<<" NAMA KELOMPOK"<<endl;
cout<<" 1. FITRI ENDANG LESTARI      [NIM : 11150264]  "<<endl;
cout<<" 2. EVI MONICA GINTING        [NIM : 11150528]  "<<endl;
cout<<" 3. SANDI KURNIAWAN RAMADHAN  [NIM : 11151190]  "<<endl;
cout<<" 4. WILDAN AGUNG MAULANA      [NIM : 11152075]  "<<endl;
cout<<" KELAS  : 11.1B.27 "<<endl;
cout<<" TAHUN AJARAN   : 2015/2016 "<<endl;
cout<<endl;
cout<<endl;
cout<<"======================================"<<endl;
cout<<" MENGHITUNG LUAS SEGITIGA "<<endl;
cout<<"======================================"<<endl;
cout<<endl;
cout<<"MASUKAN NILAI ALAS    : ",cin>>alas;
cout<<"MASUKAN NILAI TINGGI  : ",cin>>tinggi;
cout<<endl;
cout<<endl;
luas=(alas*tinggi)*0.5;
cout<<"LUAS SEGITIGA ADALAH  : "<<luas<<endl;
cout<<endl;
return 0;
}

  • Menghitung Luas Persegi Panjang
#include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main(int argc, char** argv)

{
float panjang,lebar,luas;

cout<<" NAMA KELOMPOK"<<endl;
cout<<" 1. FITRI ENDANG LESTARI      [NIM : 11150264]  "<<endl;
cout<<" 2. EVI MONICA GINTING        [NIM : 11150528]  "<<endl;
cout<<" 3. SANDI KURNIAWAN RAMADHAN  [NIM : 11151190]  "<<endl;
cout<<" 4. WILDAN AGUNG MAULANA      [NIM : 11152075]  "<<endl;
cout<<" KELAS  : 11.1B.27 "<<endl;
cout<<" TAHUN AJARAN   : 2015/2016 "<<endl;
cout<<endl;
cout<<endl;
cout<<"======================================"<<endl;
cout<<" MENGHITUNG LUAS PERSEGI PANJANG "<<endl;
cout<<"======================================"<<endl;
cout<<endl;
cout<<" MASUKAN PANJANG   = ",cin>>panjang;
cout<<endl;
cout<<" MASUKAN LEBAR     = ",cin>>lebar;
cout<<endl;
lebar=panjang*lebar;
cout<<" LUAS PERSEGI PANJANG ADALAH  = "<<lebar<<endl;
cout<<endl;
return 0;   
}

  • Menghitung Luas Bujur Sangkar
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <math.h>
#include <windows.h>

using namespace std;

int main(int argc, char** argv)

{
int sisi,bujur;

cout<<" NAMA KELOMPOK"<<endl;
cout<<" 1. FITRI ENDANG LESTARI      [NIM : 11150264]  "<<endl;
cout<<" 2. EVI MONICA GINTING        [NIM : 11150528]  "<<endl;
cout<<" 3. SANDI KURNIAWAN RAMADHAN  [NIM : 11151190]  "<<endl;
cout<<" 4. WILDAN AGUNG MAULANA      [NIM : 11152075]  "<<endl;
cout<<" KELAS  : 11.1B.27 "<<endl;
cout<<" TAHUN AJARAN   : 2015/2016 "<<endl;
cout<<endl;
cout<<endl;
cout<<" MENGHITUNG LUAS BUUJUR SANGKAR "<<endl;
cout<<"======================================"<<endl;
cout<<endl;
cout<<endl;
cout<<" MASUKAN SISI SISINYA   = ",cin>>sisi;
cout<<endl;
cout<<endl;
bujur=sisi*sisi;
cout<<" LUAS BUJUR SANGKAR     = "<<bujur<<" M2"<<endl;
cout<<endl;
return 0;       
}
 
==========================================================================
==========================================================================
==========================================================================
TUGAS KELOMPOK (MAX 5 ORANG Pertemuan 4)
di buat menggunakan Microsoft Office Visio

1. Buatlah Flowchartnya pseudocode berikut ini:
  a. Masukan Kode Barang
  b. Masukan Harga Barang
  c. Masukan Jumlah barang
  d. Hitung Bayar = Harga*jumlah barang
  e. jika bayar>= 100.000 maka di berikan discount
     10%, selain dari itu tidak mendapat discount
  f. Hitung total bayar = bayar-discount
  g. Cetak total bayar


 LANJUTAN....

2. Buatlah Flowchartnya pseudocode berikut ini:
  a. diketahui phi=3.14
  b. masukann nilai jari-jari(r)
  c. hitung keliling = 2*phi*r
  d. cetak keliling
  e. ingin pilih kembali? jika "YA" maka kembali
     ke proses awal, jika "TIDAK" maka program berhenti

LANJUTAN...

3. Buatlah Flowchartnya pseudocode berikut ini:
  a. Masukan Pilihan
  b. > Jika pilihan=1 maka menu=" nasi goreng"
      > Jika pilihan=2 maka menu=" mie goreng"
      > Jika pilihan=3 maka menu=" Capcay"
  c. Cetak menu
  d. ingin pilih kembali? jika "YA" maka kembali
      ke proses awal, jika "TIDAK" maka program berhenti.


nilainya A++ ya pak>> :-D


TUGAS KELOMPOK PERTEMUAN 13

* Buatlah Shortest path problem untuk graph dibawah ini. > cara penyelesaian SHORTEST PATH PROBLEM     - pertama : Melihat proses si...