Jumat, 08 Juli 2011

Program Penjualan Menggunakan Cpp

  Agus Nur Ikhsan       Jumat, 08 Juli 2011
#include <iostream.h>
#include <conio.h>

class penjualan{
      public:
             friend ostream& operator<<(ostream&, penjualan&);
             void cetak_nama();
             void masuk_data();
             void hitung();
             penjualan();
      private:
              char a[50],b[50],c[50],d[50],e[50];
              int data[100][100];
              int total[50],jumlah[50];
              double rata[50];
              };

    penjualan::penjualan(){
                           cout<<"Data Sales"<<endl;
                           }
                           
    void penjualan::cetak_nama(){
         int k=1;
         cout<<"Masukkan Nama "<<k<<"=";cin>>a;
         cout<<"Masukkan Nama "<<k+1<<"=";cin>>b;
         cout<<"Masukkan Nama "<<k+2<<"=";cin>>c;
         cout<<"Masukkan Nama "<<k+3<<"=";cin>>d;
         cout<<"Masukkan Nama "<<k+4<<"=";cin>>e;
                 }

    void penjualan::masuk_data(){
         for(int i=0; i<5; i++)
                 for(int j=0; j<5; j++){
                         cout<<"Masukkan data ke ["<<i+1<<"] ["<<j+1<<"] :";
                         cin>>data[i][j];

                         }
                         }

    void penjualan::hitung(){       
         for(int i=0; i<5; i++){
                 total[i]=0;
                 jumlah[i]=0;
                 for(int j=0; j<5; j++){              
                  total[i]=total[i]+data[i][j];
                  jumlah[i]=jumlah[i]+data[j][i];
                  }}
         rata[0]=0;
         jumlah[5]=0;
         for(int i=0; i<5; i++){
                 rata[i]=(rata[i]+(jumlah[i]/5));
                 jumlah[5]=jumlah[5]+jumlah[i];     
                  }
                  }
                  
    ostream& operator<<(ostream& out,penjualan& m){
             out<<"No\tNama\tJan\tFeb\tMar\tApr\tMei\tTotal"<<endl;
             out<<"1.";
             out<<"\t";        
             for(int i=0; i<strlen(m.a); i++){
                 out<<m.a[i];
                 }
             out<<"\t";
             for(int i=0; i<5; i++){
                          out<<m.data[0][i]<<"\t";
                          }
             out<<m.total[0];
             out<<endl;
             out<<"2.";
             out<<"\t";        
             for(int i=0; i<strlen(m.b); i++){
                 out<<m.b[i];
                 }
             out<<"\t";
             for(int i=0; i<5; i++){
                          out<<m.data[1][i]<<"\t";
                          }
             out<<m.total[1];
             out<<endl;
             out<<"3.";
             out<<"\t";        
             for(int i=0; i<strlen(m.c); i++){
                 out<<m.c[i];
                 }
             out<<"\t";
             for(int i=0; i<5; i++){
                          out<<m.data[2][i]<<"\t";
                          }
             out<<m.total[2];
             out<<endl;
             out<<"4.";
             out<<"\t";        
             for(int i=0; i<strlen(m.d); i++){
                 out<<m.d[i];
                 }
             out<<"\t";
             for(int i=0; i<5; i++){
                          out<<m.data[3][i]<<"\t";
                          }
             out<<m.total[3];
             out<<endl;
             out<<"5.";
             out<<"\t";
             for(int i=0; i<strlen(m.e); i++){
                 out<<m.e[i];
                 }
             out<<"\t";
             for(int i=0; i<5; i++){
                          out<<m.data[4][i]<<"\t";
                          }
             out<<m.total[4];
             out<<endl;
             out<<"\ttotal\t";
             for(int i=0; i<5; i++){
                     out<<m.jumlah[i]<<"\t";
                     }
             out<<m.jumlah[5];
             out<<endl;
             out<<"\trata2\t";
             for(int i=0; i<5; i++){
                     out<<m.rata[i]<<"\t";
                     }
             out<<"Tot Penj 5 Bln";
             out<<endl;
             }
int main()
{
   penjualan z;
   z.cetak_nama();
   z.masuk_data();
   z.hitung();
   cout<<z;

   return 0;
   getch();
}


<script type="text/javascript"><!--
google_ad_client = "ca-pub-7673530938543175";
google_ad_host = "pub-1556223355139109";
/* pengumuman */
google_ad_slot = "6867804368";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
logoblog

Thanks for reading Program Penjualan Menggunakan Cpp

Previous
« Prev Post

Tidak ada komentar:

Posting Komentar