Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Tugas Array Stok_Nov Mobil
- #include <iostream>
- #include <iomanip>
- #include <string.h>
- using namespace std;
- int main()
- {
- int mobil[10][5];
- string tipe[10][5];
- int jumlah[10];
- int btipe,i,j,maks,min,total;
- string banyak,sedikit;
- cout<<"----------------------"<<endl;
- cout<<"| Program Stok Mobil |"<<endl;
- cout<<"----------------------"<<endl;
- cout<<"Masukkan Banyaknya Tipe Mobil (Maksimal 10): ";
- cin>>btipe;
- cout<<endl;
- cout<<"Memasukkan Data Stok Mobil"<<endl;
- cout<<"(Warna 1 = Hitam, Warna 2 = Putih, Warna 3 = Merah, Warna 4 = Gold, Warna 5 = Silver)"<<endl;
- cout<<endl;
- for (i=0;i<btipe;i++)
- {
- for (j=0;j<1;j++)
- {
- cout<<"Tipe Mobil Ke-"<<i+1<<" = ";
- cin>>tipe[i][0];
- }
- for (j=1;j<6;j++)
- {
- cout<<"Stok Mobil Ke-"<<i+1<<" Warna "<<j<<" = ";
- cin>>mobil[i][j];
- }
- }
- cout<<endl;
- system("CLS");
- cout<<"Tipe Hitam Putih Merah Gold Silver"<<endl;
- for(i=0;i<btipe;i++)
- {
- for(j=0;j<1;j++)
- cout<<tipe[i][0]<<" ";
- for(j=1;j<6;j++)
- {
- cout<<setw(8)<<mobil[i][j];
- }
- cout<<endl;
- }
- cout<<endl;
- for(i=0;i<btipe;i++)
- {
- jumlah[i]=0;
- for(j=1;j<6;j++)
- {
- jumlah[i]=jumlah[i]+mobil[i][j];
- }
- cout<<"Total Stok Mobil "<<tipe[i][0]<<" = "<<jumlah[i]<<endl;
- }
- cout<<endl;
- //Menentukan Stok Paling Banyak
- maks=0;
- for(i=0;i<btipe;i++)
- for(j=1;j<6;j++)
- {
- if(maks<=jumlah[i])
- {
- maks=jumlah[i];
- banyak=tipe[i][0];
- }
- }
- cout<<"Tipe Mobil Yang Stoknya Paling Banyak : "<<banyak<<" ("<<maks<<" Mobil)"<<endl;
- cout<<endl;
- jumlah[i]=0;
- //Menentukan Stok Paling Sedikit
- min=maks;
- for(i=0;i<btipe;i++)
- for(j=1;j<6;j++)
- {
- if(min>=jumlah[i])
- {
- min=jumlah[i];
- sedikit=tipe[i][0];
- }
- }
- cout<<"Tipe Mobil Yang Stoknya Paling Sedikit : "<<sedikit<<" ("<<min<<" Mobil)"<<endl;
- cout<<endl;
- //Menghitung stok seluruh mobil
- for(i=0;i<btipe;i++)
- for(j=1;j<6;j++)
- total+=mobil[i][j];
- cout<<"Total Stok Seluruh Mobil = "<<total<<endl;
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement