Algoritma dan Pemrograman / CPP(C++) - dunia Cell

#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <iomanip.h>
main()
{
                struct
   {
                char jenis,jns[20],kode,provider[10];
      int jumlah,subtotal,pulsa,harga;
   }
   dunia[10];
   clrscr();
   char no[25];
   int i,data,total=0;
   cout<<"Daftar Harga Pulsa"<<endl;
   cout<<"__________________"<<endl<<endl<<endl;
   cout<<"Masukkan No. Transaksi = ";cin>>no;
   cout<<"Masukkan Jumlah Data   = ";cin>>data;
   for(i=1;i<=data;i++)
                {
                cout<<endl;
         cout<<"Transaksi Ke- "<<i<<endl;
         cout<<"Kode Provider[S/M]  = ";cin>> dunia[ i].kode;
         cout<<"Pulsa [20/50/100]   = ";cin>> dunia [i].pulsa;
         cout<<"Jenis Voucher [e/f] = ";cin>> dunia [i].jenis;
         cout<<"Jumlah Beli         = ";cin>> dunia [i].jumlah;
         switch (dunia [i].jenis)
         {
         case 'E':case 'e':
         strcpy(dunia [i].jns,"ELEKTRIK");
         dunia[i].jenis=0;
         break;
         case 'F':case 'f':
         strcpy(dunia [i].jns,"FISIK");
         dunia[i].jenis=1000;
         break;
         }
                switch(dunia [i].kode)
                                                {
                                                                case 'S':case 's':
                                                                strcpy(dunia [i].provider,"SIMPATI");
                                                                if (dunia [i].pulsa==20)
                                                                dunia [i].harga=21000;
                                                                else if (dunia [i].pulsa==50)
                                                                dunia [i].harga=50500;
                                                                else if (dunia [i].pulsa==100)
                                                                dunia [i].harga=98000;
                                                                else
                                                                dunia [i].harga=0;
                                                                break;
                                                                case 'M':case 'm':
                                                                strcpy(dunia[i].provider,"IM3");
                                                                if (dunia [i].pulsa==20)
                                                                dunia [i].harga=20500;
                                                                else if (dunia [i].pulsa==50)
                                                                dunia [i].harga=49000;
                                                                else if (dunia [i].pulsa==100)
                                                                dunia [i].harga=98500;
                                                                else
                                                                dunia [i].harga=0;
                                                                break;
                                                                default:
                                                                strcpy(dunia [i].provider,"---");
                                                                dunia [i].harga=0;
                                                                break;
                                                }
      }
      clrscr();
      cout<<"\t\t\tSTRUK TRANSAKSI \"DUNIA CELL\""<<endl;
      cout<<"\t\t\t____________________________"<<endl<<endl;
                cout<<"No. Transaksi : "<<no<<endl;
         cout<<"_________________________________________________________________"<<endl;
         cout<<"No | Provider | Pulsa | Voucher |   Harga | Jumlah Beli | Subtotal"<<endl;
         cout<<"_________________________________________________________________"<<endl;
   for(i=1;i<=data;i++)
                {
                cout<<setiosflags(ios::right)<<setw(1)<<i<<"        ";
         cout<<setiosflags(ios::left)<<setw(2)<< dunia [i].provider<<"         ";
         cout<<setiosflags(ios::left)<<setw(20)<< dunia [i].pulsa;
         cout<<setiosflags(ios::left)<<setw(3)<< dunia [i].jns<<"     ";
         cout<<setiosflags(ios::left)<<setw(5)<< dunia [i].harga<<"Rp. ";
         cout<<setiosflags(ios::left)<<setw(6)<< dunia [i].jumlah<<"   ";
         yuhaza [i].subtotal= yuhaza [i].harga* dunia [i].jumlah;
         cout<<setiosflags(ios::left)<<setw(7)<< dunia [i].subtotal<<endl;
         total=total+ dunia[i].subtotal;
      }
                cout<<"_________________________________________________________________"<<endl;
         cout<<"Total Bayar = Rp. "<<total;
getch();
}

No comments:

Post a Comment