This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Jumat, 25 Mei 2012

program kalkulator

#include <conio.h>
#include <iostream>
#include <math.h>
#define PI 3.14159265

using namespace std;

class kalkulator{
      friend istream& operator>>(istream&, kalkulator&);
      public:
             kalkulator();
             void pilih();
             void absolut();
             void pangkat2();
             void pangkat3();
             void akar();
             void eksponen();
             void cosinus();
             void sinus();
      private :
             int op;     
};

istream& operator>>(istream& in, kalkulator& x){
    cout<<"Pilih : ";
    in>>x.op;
    return in;        
}

kalkulator::kalkulator(){
cout<<"KALKULATOR SEDERHANA, SESEDERHANA MUNGKIN"<<endl;
    cout<<"-----------------------------------------"<<endl;
    cout<<"MENU"<<endl<<endl;
    cout<<"1. absolut"<<endl;
    cout<<"2. pangkat 2"<<endl;
    cout<<"3. pangkat 3"<<endl;
    cout<<"4. akar"<<endl;
    cout<<"5. eksponen"<<endl;
    cout<<"6. cos"<<endl<<endl;
}

void kalkulator::pilih(){
    switch(op){
    case 1 : absolut();break;
    case 2 : pangkat2();break;
    case 3 : pangkat3();break;
    case 4 : akar();break;
    case 5 : eksponen();break;
    case 6 : cosinus();break;
    default :cout<<"Pilihan tidak ada";          
    }
}

void kalkulator::absolut(){
    int angka;
    cout<<"\nABSOLUT\n";
    cout<<"Masukkan bilangan integer : ";
    cin>>angka;
    cout<<"Absolut dari " << angka << " adalah : " << abs(angka);
}

void kalkulator::pangkat2(){
    int angka;
    cout<<"\nPANGKAT 2\n";
    cout<<"Masukkan bilangan integer : ";
    cin>>angka;
    cout<<"Pangkat 2 dari " << angka << " adalah : " << angka * angka; 
}

void kalkulator::pangkat3(){
    int angka;
    cout<<"\nPANGKAT 3\n";
    cout<<"Masukkan bilangan integer : ";
    cin>>angka;
    cout<<"Pangkat 3 dari " << angka << " adalah : " << angka * angka * angka;  
}

void kalkulator::akar(){
    int angka;
    cout<<"\nAKAR\n";
    cout<<"Masukkan bilangan integer : ";
    cin>>angka;
    cout<<"Akar dari " << angka << " adalah : " << sqrt(angka);
}

void kalkulator::eksponen(){
    int angka;
    cout<<"\nEKSPONEN\n";
    cout<<"Masukkan bilangan integer : ";
    cin>>angka;
    cout<<"Eksponen dari " << angka << " adalah : " << exp(angka);  
}

void kalkulator::cosinus(){
    int angka;
    cout<<"\nCOSINUS\n";
    cout<<"Masukkan bilangan integer : ";
    cin>>angka;
    cout<<"Cos dari " << angka << " adalah : " << cos(angka*PI/180);
}

void kalkulator::sinus(){
    cout<<"\nSINUS\n";
}

int main(){ 
    kalkulator kal;
    cin>>kal;
    kal.pilih();
   
    cout<<"\n\nTekan sembarang tombol untuk keluar ...";
       
    getch();
}

tahun kabisat

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

using namespace std;

class kabisat{
      friend istream& operator>>(istream&, kabisat&);
      public:
             //kabisat(char *kata_awal=""):hasil(kata_awal){
               //           cout<<"selamat\n";}
             kabisat(char *kata_awal=""):hasil(kata_awal){};
             void cetak(){cout<<hasil;}
      private:
              char *hasil;
              int input;
};

istream& operator>>(istream& in, kabisat& a){
     cout<<"Input \t: ";
     in>>a.input;
     return in;           
}

main(){
     kabisat hasil1("Kabisat");
     kabisat hasil2("Bukan Kabisat");
    
     if(2000 % 4 == 0){hasil1.cetak();}
     else{hasil2.cetak();}
         
     getch();
     return 0;
}

program himpunan

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

using namespace std;

int main(){
    int i, j, a[20], b[20], banyakA, banyakB;
   
    cout<<"IRISAN & GABUNGAN 2 HIMPUNAN\n";
    cout<<"============================\n\n";
    cout<<"Masukkan banyaknya anggota himpunan A : ";
    cin>>banyakA;
   
    for(i=0;i<banyakA;i++){
    cout<<"Masukkan anggota " << i+1 << " : ";
    cin>>a[i];
    }
   
    cout<<"\nMasukkan banyaknya anggota himpunan B : ";
    cin>>banyakB;
   
    for(i=0;i<banyakB;i++){
    cout<<"Masukkan anggota " << i+1 << " : ";
    cin>>b[i];
    }
   
    cout<<"\nHimpunan A={ ";
    for(i=0;i<banyakA;i++){
    cout<<a[i]<<" ";
    }
    cout<<"}";
   
    cout<<"\nHimpunan B={ ";
    for(i=0;i<banyakB;i++){
    cout<<b[i]<<" ";
    }
    cout<<"}";
   
    cout<<"\n\n-----------------------------\n";
    cout<<"A irisan B = { ";
    for(i=0;i<banyakA;i++){
    for(j=0;j<banyakB;j++){
    if(a[i]==b[j]) cout<<a[i]<<" ";
    }
    }
    cout<<"}";
   
    cout<<"\n\nA gabungan B = { ";
    for(i=0;i<banyakA;i++){
    cout<<a[i]<<" ";
    }
    for(i=0;i<banyakB;i++){
    cout<<b[i]<<" ";
    }
    cout<<"}";
   
    cout<<"\n\nTekan sembarang untuk keluar ...";
    getch();
    return 0;  
}

program faktor

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

using namespace std;

void CariFaktor(int n){
/*Mencari faktor dari bilangan bulat n selain 1 dan n itu sendiri.
  Masukan: n
  Keluaran: setiap bilangan yang menjadi faktor n dicetak.*/
 
  int k;
 
  k=1;
  //ketemu=false;
  for (k=2; k<n-1; k++){
    if (n%k == 0)cout<<k<<" ";
  }
}

main(){
       int angka;
       cout<<"Masukkan angka : ";
       cin>>angka;
       cout<<"Faktor : ";
       CariFaktor(angka);
      
       getch();      
}

program jual bensin

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

using namespace std;

void menu(){
     cout<<"JENIS BAHAN BAKAR\t HARGA"<<endl;
     cout<<"1. Bensin \t\t Rp 4500/lt"<<endl;
     cout<<"2. Solar \t\t Rp 4000/lt"<<endl;
     cout<<"3. Pertamax \t\t Rp 5000/lt"<<endl;
     cout<<"4. Avtur \t\t Rp 8000/lt"<<endl;
}

int main(){
    int uang, pilih, total;
    int liter;
    cout<<"------------------------------------------------"<<endl;
    cout<<"           PROGRAM MEMBELI BAHAN BAKAR          "<<endl;
    cout<<"------------------------------------------------"<<endl;
    uang :
    cout<<"Masukkan uang anda : Rp ";
    cin>>uang;

    if(uang<4000){
               cout<<"Sori mas, uangnya tidak boleh dibawah Rp 4500"<<endl;
               goto uang;
    }
    else{
         cout<<endl;
         menu();
         milih :
         cout<<"\nMasukkan Pilihan Anda : ";
         cin>>pilih;
         switch(pilih){
          case 1 :
               if(uang<4500) {
                             cout<<"Maaf, uang Anda tidak cukup untuk membeli bensin."<<endl;
                             goto milih;
                             }
               else {
               cout<<"BENSIN"<<endl;
               literbensin:
               cout<<"Berapa Liter? "; cin>>liter;
               total=liter*4500;
               if(total>uang){
                              cout<<"Anda hanya dapat membeli maksimal "<<uang/4500<<" liter.\n"<<endl; goto literbensin;
               }else{
                     cout<<"\nMulai dari 0 ya!"<<endl;
                     cout<<endl;
                                for(float i=0;i<=liter;i=i+0.1){
                                          cout<<i<<" ";
                                }
                     cout<<endl;
                     cout<<"\n------------------------------------------------"<<endl;
                     cout<<"Total Pembayaran \t: Rp "<<total<<endl;
                     cout<<"Uang Anda \t\t: Rp "<<uang<<endl;
                     cout<<"Kembalian \t\t: Rp "<<uang-total<<endl;
               }
               }
              
          break;
          case 2 : cout<<"SOLAR"<<endl;
                   litersolar:
                   cout<<"Berapa Liter? "; cin>>liter;
                   total=liter*4000;
                   if(total>uang){
                                  cout<<"Anda hanya dapat membeli maksimal "<<uang/4000<<" liter.\n"<<endl; goto litersolar;
                   }else{
                     cout<<"\nMulai dari 0 ya!"<<endl;
                     cout<<endl;
                                for(float i=0;i<=liter;i=i+0.1){
                                          cout<<i<<" ";
                                }
                     cout<<endl;
                     cout<<"\n------------------------------------------------"<<endl;
                     cout<<"Total Pembayaran \t: Rp "<<total<<endl;
                     cout<<"Uang Anda \t\t: Rp "<<uang<<endl;
                     cout<<"Kembalian \t\t: Rp "<<uang-total<<endl;
               }                   
          break;
          case 3 :
                   if(uang<5000) {
                             cout<<"Maaf, uang Anda tidak cukup untuk membeli pertamax."<<endl;
                             goto milih;
                             }
               else {
               cout<<"PERTAMAX"<<endl;
               literpertamax:
               cout<<"Berapa Liter? "; cin>>liter;
               total=liter*5000;
               if(total>uang){
                              cout<<"Anda hanya dapat membeli maksimal "<<uang/5000<<" liter.\n"<<endl; goto literpertamax;
               }else{
                     cout<<"\nMulai dari 0 ya!"<<endl;
                     cout<<endl;
                                for(float i=0;i<=liter;i=i+0.1){
                                          cout<<i<<" ";
                                }
                     cout<<endl;
                     cout<<"\n------------------------------------------------"<<endl;
                     cout<<"Total Pembayaran \t: Rp "<<total<<endl;
                     cout<<"Uang Anda \t\t: Rp "<<uang<<endl;
                     cout<<"Kembalian \t\t: Rp "<<uang-total<<endl;
               }
               }
          break;
          case 4 :
               if(uang<8000) {
                             cout<<"Maaf, uang Anda tidak cukup untuk membeli avtur."<<endl;
                             goto milih;
                             }
               else {
               cout<<"AVTUR"<<endl;
               literavtur:
               cout<<"Berapa Liter? "; cin>>liter;
               total=liter*8000;
               if(total>uang){
                              cout<<"Anda hanya dapat membeli maksimal "<<uang/8000<<" liter.\n"<<endl; goto literavtur;
               }else{
                     cout<<"\nMulai dari 0 ya!"<<endl;
                     cout<<endl;
                                for(float i=0;i<=liter;i=i+0.1){
                                          cout<<i<<" ";
                                }
                     cout<<endl;
                     cout<<"\n------------------------------------------------"<<endl;
                     cout<<"Total Pembayaran \t: Rp "<<total<<endl;
                     cout<<"Uang Anda \t\t: Rp "<<uang<<endl;
                     cout<<"Kembalian \t\t: Rp "<<uang-total<<endl;
               }
               }
              
               break;
          default :
                  cout<<"Ra ono mas ...";
                  goto milih;
     }
    }   
   
    cout<<endl;
    cout<<"Tekan [q] untuk keluar."<<endl;
    getch();
    return 0;
}

program sederhana

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

using namespace std;

int main(){
    int i, j, k, x;
    cout<<"PROGRAM MEMBUAT PERSEGI DENGAN [*]"<<endl;
    cout<<"----------------------------------"<<endl;
    cout<<"Masukkan panjang sisi : ";
    cin>>x;
    for(i=1;i<=x;i++){
                  cout<<endl;
                      for(j=1;j<=x;j++){
                              if(i==1 || i==x || j==1 || j==x){
                              cout<<"* ";
                              }else{
                              cout<<"  ";
                              }
                      }
    }
   
    getch();
    return 0;  
}

Selasa, 17 April 2012

computer network

computer network, often simply referred to as a network, is a collection of hardware components and computers interconnected by communication channels that allow sharing of resources and information. Where at least one process in one device is able to send/receive data to/from at least one process residing in a remote device, then the two devices are said to be in a network.
Networks may be classified according to a wide variety of characteristics such as the medium used to transport the data, communication protokol used, scale, topology, and organizational scope.
Communications protocols define the rules and data formats for exchanging information in a computer network, and provide the basis for network progrming Well-known communications protocols are ethernet a hardware and link layer standard that is ubiquitous in local area networks and the internet protocol suite, which defines a set of protocols for internetworking, i.e. for data communication between multiple networks, as well as host-to-host data transfer, and application-specific data transmission formats.
Computer networking is sometimes considered a sub-discipline of electrical engineering, telecommunications, computer science, information technology or computer engineering, since it relies upon the theoretical and practical application of these disciplines.