Contoh Program Minimarket C++

Contoh Program Minimarket C++

Berikut adalah contoh program minimarket lengkap yang ditulis dalam bahasa pemrograman C++

C++
#include <iostream>
#include <string>
#include <vector>

using namespace std;

// Struktur data untuk menyimpan informasi produk
struct Product {
    string name;
    int price;
    int quantity;
};

// Fungsi untuk menambahkan produk ke dalam daftar
void addProduct(vector<Product>& productList, string name, int price, int quantity) {
    Product newProduct;
    newProduct.name = name;
    newProduct.price = price;
    newProduct.quantity = quantity;
    productList.push_back(newProduct);
}

// Fungsi untuk mencetak daftar produk
void printProductList(const vector<Product>& productList) {
    cout << "Daftar Produk:" << endl;
    for (const Product& product : productList) {
        cout << "Nama: " << product.name << endl;
        cout << "Harga: " << product.price << endl;
        cout << "Jumlah: " << product.quantity << endl;
        cout << "------------------------" << endl;
    }
}

// Fungsi untuk menghitung total harga belanja
int calculateTotalPrice(const vector<Product>& productList) {
    int totalPrice = 0;
    for (const Product& product : productList) {
        totalPrice += product.price * product.quantity;
    }
    return totalPrice;
}

int main() {
    vector<Product> productList;

    // Menambahkan produk ke dalam daftar
    addProduct(productList, "Sabun Mandi", 5000, 10);
    addProduct(productList, "Shampoo", 10000, 5);
    addProduct(productList, "Pasta Gigi", 7000, 8);

    // Mencetak daftar produk
    printProductList(productList);

    // Menghitung total harga belanja
    int totalPrice = calculateTotalPrice(productList);
    cout << "Total Harga: " << totalPrice << endl;

    return 0;
}
C++

Program di atas adalah contoh program minimarket yang menggunakan struktur data Product untuk menyimpan informasi produk seperti nama, harga, dan jumlah. Program ini memiliki beberapa fungsi, antara lain:

  • addProduct: Fungsi ini digunakan untuk menambahkan produk ke dalam daftar. Fungsi ini menerima parameter berupa vector productList, nama produk, harga, dan jumlah produk.
  • printProductList: Fungsi ini digunakan untuk mencetak daftar produk yang ada dalam vector productList.
  • calculateTotalPrice: Fungsi ini digunakan untuk menghitung total harga belanja berdasarkan daftar produk yang ada dalam vector productList.

Di dalam fungsi main, terdapat contoh penggunaan program minimarket ini. Beberapa produk ditambahkan ke dalam daftar menggunakan fungsi addProduct, kemudian daftar produk dicetak menggunakan fungsi printProductList. Selanjutnya, total harga belanja dihitung menggunakan fungsi calculateTotalPrice dan dicetak ke layar.

Contoh lain

C++
#include <iostream>
#include <string>
#include <conio.h>
#include <windows.h>
#include <stdlib.h>

using namespace std;

void beku();
void beli();
void buah();
void juice();
void kopi();
void makanan();
void menuhh();
void mineral();
void minuman();
void sayur();
void sembako();
void snack();
void soda();
void susu();
void teh();

void snack()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"********** SNACK ***************"<<endl<<endl<<endl;
    cout<<" 1. Chitato"<<endl;
    cout<<" 2. Kusuka"<<endl;
    cout<<" 3. Cheetos"<<endl;
    cout<<" 4. Taro"<<endl;
    cout<<" 5. Lays"<<endl;
    cout<<endl<<endl;
    cout<<"Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=5800;
        cout<<"                      Chitato"<<endl;
        cout<<"                      Product Code = 0011112345"<<endl;
        cout<<"                      Price        = RP. 5.800"<<endl;
        break;
    case 2 :
        HARGA=6500;
        cout<<"                      Kusuka"<<endl;
        cout<<"                      Product Code = 0011212345"<<endl;
        cout<<"                      Price        = RP. 6.500"<<endl;
        break;
    case 3 :
        HARGA=4200;
        cout<<"                      Cheetos"<<endl;
        cout<<"                      Product Code = 0011312345"<<endl;
        cout<<"                      Price        = RP. 4.200"<<endl;
        break;
    case 4 :
        HARGA=2500;
        cout<<"                      Taro"<<endl;
        cout<<"                      Product Code = 0011412345"<<endl;
        cout<<"                      Price        = RP. 2.500"<<endl;
        break;
    case 5 :
        HARGA=5500;
        cout<<"                      Lays"<<endl;
        cout<<"                      Product Code = 0011512345"<<endl;
        cout<<"                      Price        = RP. 5.500"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"                          Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"                          YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"                          TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"                          TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}

void buah()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"*************************************** BUAH ***************************************"<<endl<<endl<< endl;
    cout<<"                                      1. Apel"<<endl;
    cout<<"                                      2. Jeruk"<<endl;
    cout<<"                                      3. Pisang"<<endl;
    cout<<"                                      4. Semangka"<<endl;
    cout<<"                                      5. Melon"<<endl;
    cout<<endl<<endl;
    cout<<"                                      Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=4000;
        cout<<"                       Apel"<<endl;
        cout<<"                       Product Code = 0012112345"<<endl;
        cout<<"                       Price        = RP. 4000"<<endl;
        break;
    case 2 :
        HARGA=3800;
        cout<<"                       Jeruk"<<endl;
        cout<<"                       Product Code = 0012212345"<<endl;
        cout<<"                       Price        = RP. 3.800"<<endl;
        break;
    case 3 :
        HARGA=3000;
        cout<<"                       Pisang"<<endl;
        cout<<"                       Product Code = 0012312345";
        cout<<"                       Price        = RP. 3.000";
        break;
    case 4 :
        HARGA=15000;
        cout<<"                       Semangka"<<endl;
        cout<<"                       Product Code = 0012412345"<<endl;
        cout<<"                       Price        = RP. 15.000"<<endl;
        break;
    case 5 :
        HARGA=17500;
        cout<<"                       Melon"<<endl;
        cout<<"                       Product Code = 0012512345"<<endl;
        cout<<"                       Price        = RP. 17.500"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"                           Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"                           YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"                           TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"                           TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}

void sayur()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"************************************** SAYUR ***************************************"<<endl<<endl<< endl;
    cout<<"                                     1. Kentang"<<endl;
    cout<<"                                     2. Brokoli"<<endl;
    cout<<"                                     3. Bayam"<<endl;
    cout<<"                                     4. Timun"<<endl;
    cout<<"                                     5. Wortel"<<endl;
    cout<<endl<<endl;
    cout<<"                                     Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=1500;
        cout<<"                     Kentang"<<endl;
        cout<<"                     Product Code = 0013112345"<<endl;
        cout<<"                     Price        = RP. 1.500"<<endl;
        break;
    case 2 :
        HARGA=6500;
        cout<<"                     Brokoli"<<endl;
        cout<<"                     Product Code = 0013212345"<<endl;
        cout<<"                     Price        = RP. 6.500"<<endl;
        break;
    case 3 :
        HARGA=2200;
        cout<<"                     Bayam"<<endl;
        cout<<"                     Product Code = 0013312345"<<endl;
        cout<<"                     Price        = RP. 2.200"<<endl;
        break;
    case 4 :
        HARGA=2500;
        cout<<"                     Timun"<<endl;
        cout<<"                     Product Code = 0013412345"<<endl;
        cout<<"                     Price        = RP. 2.500"<<endl;
        break;
    case 5 :
        HARGA=2800;
        cout<<"                     Wortel"<<endl;
        cout<<"                     Product Code = 0013512345"<<endl;
        cout<<"                     Price        = RP. 2.800"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"                         Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"                         YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"                         TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"                         TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}

void beku()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"*********************************** MAKANAN BEKU ************************************"<<endl<<endl;
    cout<<"                                   1. Nugget"<<endl;
    cout<<"                                   2. Sosis"<<endl;
    cout<<"                                   3. French Fries"<<endl;
    cout<<"                                   4. Daging Ayam"<<endl;
    cout<<"                                   5. Daging Sapi"<<endl;
    cout<<endl<<endl;
    cout<<"                                   Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=27000;
        cout<<"                     Nugget"<<endl;
        cout<<"                     Product Code = 0014112345"<<endl;
        cout<<"                     Price        = RP. 27.000"<<endl;
        break;
    case 2 :
        HARGA=18500;
        cout<<"                     Sosis"<<endl;
        cout<<"                     Product Code = 0014212345"<<endl;
        cout<<"                     Price        = RP. 18.500"<<endl;
        break;
    case 3 :
        HARGA=28800;
        cout<<"                     French Fries"<<endl;
        cout<<"                     Product Code = 0014312345"<<endl;
        cout<<"                     Price        = RP. 28.800"<<endl;
        break;
    case 4 :
        HARGA=32000;
        cout<<"                     Daging Ayam"<<endl;
        cout<<"                     Product Code = 0014412345"<<endl;
        cout<<"                     Price        = RP. 32.000"<<endl;
        break;
    case 5 :
        HARGA=78500;
        cout<<"                     Daging Sapi"<<endl;
        cout<<"                     Product Code = 0014512345"<<endl;
        cout<<"                     Price        = RP. 78.500"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"                         Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"                        YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"                        TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"                        TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}

void sembako()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"********** SEMBAKO *********"<<endl<<endl;
    cout<<"1. Beras"<<endl;
    cout<<"2. Minyak"<<endl;
    cout<<"3. Terigu"<<endl;
    cout<<"4. Gula"<<endl;
    cout<<"5. Indomie"<<endl;
    cout<<endl<<endl;
    cout<<"Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=8500;
        cout<<"Beras"<<endl;
        cout<<"Product Code = 0015112345"<<endl;
        cout<<"Price        = RP. 8.500"<<endl;
        break;
    case 2 :
        HARGA=12000;
        cout<<"Minyak"<<endl;
        cout<<"Product Code = 0015212345"<<endl;
        cout<<"Price        = RP. 12.000"<<endl;
        break;
    case 3 :
        HARGA=8000;
        cout<<"Terigu"<<endl;
        cout<<"Product Code = 0015312345"<<endl;
        cout<<"Price        = RP. 8.000"<<endl;
        break;
    case 4 :
        HARGA=7000;
        cout<<"Gula"<<endl;
        cout<<"Product Code = 0015412345"<<endl;
        cout<<"Price        = RP. 7.000"<<endl;
        break;
    case 5 :
        HARGA=2500;
        cout<<"Indomie"<<endl;
        cout<<"Product Code = 0015512345"<<endl;
        cout<<"Price        = RP. 2.500"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}
void makanan()
{
	system("cls");
	
	int menu1, snack(), buah(), sayur(), beku(), sembako();
	
	cout<<">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MAKANAN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<< endl<< endl<< endl;
	cout<<"                                         1. Snack"<< endl;
	cout<<"                                         2. Buah"<< endl;
	cout<<"                                         3. Sayur"<< endl;
	cout<<"                                         4. Makanan Beku"<< endl;
	cout<<"                                         5. Sembako"<< endl<< endl;
	cout<<"                                         Pilihan anda [1/2/3/4/5] = ";
	cin>> menu1;
	cin.ignore();
	
	if(menu1 == 1)
	{
		snack();
	}
	else if(menu1 == 2)
	{
		buah();
	}
	else if(menu1 == 3)
	{
		sayur();
    } 
    else if(menu1 == 4)
    {
      beku();
  }
  else if(menu1 == 5)
  {
      sembako();
  }
  else
  {
      cout<<"              Perintah tidak diketahui";
  }
}
void soda()
{
  long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
  string menu;

  system("cls");
  cout<<"************************************ SODA ****************************************"<< endl<< endl<< endl;
  cout<<"                                 1. Coca - Cola"<<endl;
  cout<<"                                 2. Sprite"<<endl;
  cout<<"                                 3. Fanta"<<endl;
  cout<<"                                 4. Big Cola"<<endl;
  cout<<"                                 5. Pepsi"<<endl;
  cout<<endl<<endl;
  cout<<"                                 Enter Your Choice [1/2/3/4/5] = ";
  cin>> MENU;
  cin.ignore();
  cout<<endl;

  switch (MENU)
  {
  case 1 :
    HARGA=9500;
    cout<<"                Coca - Cola "<<endl;
    cout<<"                Product Code = 0021112345"<<endl;
    cout<<"                Price        = RP. 9.500"<<endl;
    break;
case 2 :
    HARGA=9500;
    cout<<"                Sprite"<<endl;
    cout<<"                Product Code = 0021212345"<<endl;
    cout<<"                Price        = RP. 9.500"<<endl;
    break;
case 3 :
    HARGA=8500;
    cout<<"                Fanta"<<endl;
    cout<<"                Product Code = 0021312345"<<endl;
    cout<<"                Price        = RP. 8.500"<<endl;
    break;
case 4 :
    HARGA=5500;
    cout<<"                Big Cola"<<endl;
    cout<<"                Product Code = 0021412345"<<endl;
    cout<<"                Price        = RP. 5.500"<<endl;
    break;
case 5 :
    HARGA=9000;
    cout<<"               Pepsi"<<endl;
    cout<<"               Product Code = 0021512345"<<endl;
    cout<<"               Price        = RP. 9.000"<<endl;
    break;
}
cout<<endl<<endl;

cout<<"                   Quantity about your order = ";
cin >>QUANTITY;
cin.ignore();

if(QUANTITY >= 2)
{
    DISC=(0.1*HARGA*QUANTITY);
}
else
{
   DISC=0;
}

cout<<endl;
cout<<"                   YOUR DISCOUNT = "<<DISC<<"\n";

HARGAS=(HARGA*QUANTITY);
TOTALPAY=(HARGA*QUANTITY)-DISC;
cout<<"                   TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

cout<<endl;
cout<<"                   TOTAL PEMBAYARAN = "<<TOTALPAY;

cout<<endl<<endl<<endl;

cout<<"Kembali (Ya/Tidak) ? ";
getline(cin, menu);

if(menu=="ya"||menu=="Ya"||menu=="YA")
{
   menuhh();
}
else(menu=="Tidak"||menu=="tidak");
{
 system("cls");
}
}

void mineral()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"********** Air Mineral *********"<<endl<<endl;
    cout<<"1. Aqua"<<endl;
    cout<<"2. 2 Tang"<<endl;
    cout<<"3. Total"<<endl;
    cout<<"4. Evian"<<endl;
    cout<<"5. Le Mineral"<<endl;
    cout<<endl<<endl;
    cout<<"Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=3500;
        cout<<"Aqua"<<endl;
        cout<<"Product Code = 0022112345"<<endl;
        cout<<"Price        = RP. 3.500"<<endl;
        break;
    case 2 :
        HARGA=3000;
        cout<<"2 Tang"<<endl;
        cout<<"Product Code = 0022212345"<<endl;
        cout<<"Price        = RP. 3.000"<<endl;
        break;
    case 3 :
        HARGA=3000;
        cout<<"Total"<<endl;
        cout<<"Product Code = 0022312345"<<endl;
        cout<<"Price        = RP. 3.000"<<endl;
        break;
    case 4 :
        HARGA=13.000;
        cout<<"Evian"<<endl;
        cout<<"Product Code = 0022412345"<<endl;
        cout<<"Price        = RP. 13.000"<<endl;
        break;
    case 5 :
        HARGA=3500;
        cout<<"Le Mineral"<<endl;
        cout<<"Product Code = 0022512345"<<endl;
        cout<<"Price        = RP. 3.500"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}

void juice()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"****************************************** JUICE *************************************"<<endl<<endl;
    cout<<"                                       1. Floridina"<<endl;
    cout<<"                                       2. Vit Levite"<<endl;
    cout<<"                                       3. Buavita"<<endl;
    cout<<"                                       4. You C1000"<<endl;
    cout<<"                                       5. Jungle Juice"<<endl;
    cout<<endl<<endl;
    cout<<"                                       Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=3000;
        cout<<"                    Floridina"<<endl;
        cout<<"                    Product Code = 0023112345"<<endl;
        cout<<"                    Price        = RP. 3.000"<<endl;
        break;
    case 2 :
        HARGA=4400;
        cout<<"                    Vit Levite"<<endl;
        cout<<"                    Product Code = 0023212345"<<endl;
        cout<<"                    Price        = RP. 4.400"<<endl;
        break;
    case 3 :
        HARGA=7000;
        cout<<"                   Buavita"<<endl;
        cout<<"                   Product Code = 0023312345"<<endl;
        cout<<"                   Price        = RP. 7.000"<<endl;
        break;
    case 4 :
        HARGA=7000;
        cout<<"                   You C1000"<<endl;
        cout<<"                   Product Code = 0023412345"<<endl;
        cout<<"                   Price        = RP. 7.000"<<endl;
        break;
    case 5 :
        HARGA=6000;
        cout<<"                  Jungle Juice"<<endl;
        cout<<"                  Product Code = 0023512345"<<endl;
        cout<<"                  Price        = RP. 7.000"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"                      Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"                    YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"                    TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"                    TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}


void susu()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"***************************************** SUSU **************************************"<<endl<<endl;
    cout<<"                                      1. Lotte Milk"<<endl;
    cout<<"                                      2. Ultra Milk"<<endl;
    cout<<"                                      3. Indomilk"<<endl;
    cout<<"                                      4. Frisian Flag"<<endl;
    cout<<"                                      5. Starway"<<endl;
    cout<<endl<<endl;
    cout<<"                                      Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=7600;
        cout<<"                 Lotte Milkis"<<endl;
        cout<<"                 Product Code = 0024112345"<<endl;
        cout<<"                 Price        = RP. 7.600"<<endl;
        break;
    case 2 :
        HARGA=5300;
        cout<<"                 Ultra Milk"<<endl;
        cout<<"                 Product Code = 0024212345"<<endl;
        cout<<"                 Price        = RP. 5.300"<<endl;
        break;
    case 3 :
        HARGA=4700;
        cout<<"                 Indomilk"<<endl;
        cout<<"                 Product Code = 0024312345"<<endl;
        cout<<"                 Price        = RP. 4.700"<<endl;
        break;
    case 4 :
        HARGA=5400;
        cout<<"                 Frisian Flag"<<endl;
        cout<<"                 Product Code = 0024412345"<<endl;
        cout<<"                 Price        = RP. 5.400"<<endl;
        break;
    case 5 :
        HARGA=4600;
        cout<<"                 Starway"<<endl;
        cout<<"                 Product Code = 0024512345"<<endl;
        cout<<"                 Price        = RP. 4.600"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"                     Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"                     YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"                     TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"                     TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}

void teh()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"********** TEH *********"<<endl<<endl;
    cout<<"1. Fruit Tea"<<endl;
    cout<<"2. My Tea"<<endl;
    cout<<"3. S-Tee"<<endl;
    cout<<"4. Sosro"<<endl;
    cout<<"5. Ichi Ocha"<<endl;
    cout<<endl<<endl;
    cout<<"Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=6600;
        cout<<"Fruit Tea"<<endl;
        cout<<"Product Code = 0025112345"<<endl;
        cout<<"Price        = RP. 6.600"<<endl;
        break;
    case 2 :
        HARGA=7000;
        cout<<"My Tea"<<endl;
        cout<<"Product Code = 0025212345"<<endl;
        cout<<"Price        = RP. 7.000"<<endl;
        break;
    case 3 :
        HARGA=4000;
        cout<<"S-Tee"<<endl;
        cout<<"Product Code = 0025312345"<<endl;
        cout<<"Price        = RP. 4.000"<<endl;
        break;
    case 4 :
        HARGA=6700;
        cout<<"Sosro"<<endl;
        cout<<"Product Code = 0025412345"<<endl;
        cout<<"Price        = RP. 6.700"<<endl;
        break;
    case 5 :
        HARGA=5400;
        cout<<"Ichi Ocha"<<endl;
        cout<<"Product Code = 0025512345"<<endl;
        cout<<"Price        = RP. 5.400"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"Kembali (Ya/Tidak) ? ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}

void kopi()
{
	long int MENU,HARGA,QUANTITY,TOTALPAY,DISC, HARGAS;
    string menu;

    system("cls");
    cout<<"*************************************************** KOPI **************************************************************"<<endl<<endl;
    cout<<"                                                 1. ABC Exo"<<endl;
    cout<<"                                                 2. Kopiko 78c"<<endl;
    cout<<"                                                 3. Nescafe Smoovlatte"<<endl;
    cout<<"                                                 4. Good Day"<<endl;
    cout<<"                                                 5. Polaris"<<endl;
    cout<<endl<<endl;
    cout<<"                                                 Enter Your Choice [1/2/3/4/5] = ";
    cin>> MENU;
    cin.ignore();
    cout<<endl;

    switch (MENU)
    {
    case 1 :
        HARGA=6500;
        cout<<"                     ABC Exo"<<endl;
        cout<<"                     Product Code = 0026112345"<<endl;
        cout<<"                     Price        = RP. 6.500"<<endl;
        break;
    case 2 :
        HARGA=6000;
        cout<<"                     Kopiko 78c"<<endl;
        cout<<"                     Product Code = 002621245"<<endl;
        cout<<"                     Price        = RP. 6.000"<<endl;
        break;
    case 3 :
        HARGA=7500;
        cout<<"                     Nescafe Smoovlatte"<<endl;
        cout<<"                     Product Code = 0026312345"<<endl;
        cout<<"                     Price        = RP. 7.500"<<endl;
        break;
    case 4 :
        HARGA=6700;
        cout<<"                     Good Day"<<endl;
        cout<<"                     Product Code = 0026412345"<<endl;
        cout<<"                     Price        = RP. 6.700"<<endl;
        break;
    case 5 :
        HARGA=6300;
        cout<<"                     Polaris"<<endl;
        cout<<"                     Product Code = 0026512345"<<endl;
        cout<<"                     Price        = RP. 6.300"<<endl;
        break;
    }
    cout<<endl<<endl;

    cout<<"                         Quantity about your order = ";
    cin >>QUANTITY;
    cin.ignore();

    if(QUANTITY >= 2)
    {
        DISC=(0.1*HARGA*QUANTITY);
    }
    else
    {
       DISC=0;
   }
   
   cout<<endl;
   cout<<"                          YOUR DISCOUNT = "<<DISC<<"\n";

   HARGAS=(HARGA*QUANTITY);
   TOTALPAY=(HARGA*QUANTITY)-DISC;
   cout<<"                          TOTAL SEMENTARA-DISCOUNT = "<<HARGAS<<"-"<<DISC;

   cout<<endl;
   cout<<"                          TOTAL PEMBAYARAN = "<<TOTALPAY;
   
   cout<<endl<<endl<<endl;
   
   cout<<"                          Kembali (Ya/Tidak) = ";
   getline(cin, menu);
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}
void minuman()
{
	system("cls");
	int menu1, soda(), mineral(), juice(), susu(), teh(), kopi();
	
	cout<<">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MINUMAN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<< endl<< endl<< endl;
	cout<<"                                                1. Soda"<< endl;
	cout<<"                                                2. Air Mineral"<< endl;
	cout<<"                                                3. Juice"<< endl;
	cout<<"                                                4. Susu"<< endl;
	cout<<"                                                5. Teh"<< endl;
	cout<<"                                                6. Kopi"<< endl<< endl;
	cout<<"                                                Pilihan anda [1/2/3/4/5//6] = ";
	cin>> menu1;
	cin.ignore();
	
	if(menu1 == 1)
	{
		soda();
	}
	else if(menu1 == 2)
	{
		mineral();
	}
	else if(menu1 == 3)
	{
		juice();
    } 
    else if(menu1 == 4)
    {
      susu();
  }
  else if(menu1 == 5)
  {
      teh();
  }
  else if(menu1 == 6)
  {
      kopi();
  }
  else
  {
      cout<<"Perintah tidak diketahui";
  }
}

void beli() 
{
	system("cls");
	
	int menu1;
	
	cout<<"-------------------------------------------------------PEMBELIAN-------------------------------------------------------"<< endl<< endl;
	cout<<"                                                     1. MAKANAN"<< endl;
	cout<<"                                                     2. MINUMAN"<< endl<< endl;
	cout<<"                                                     Pilihan anda [1/2] = ";
	cin>> menu1;
	cin.ignore();
	
	if(menu1 == 1)
	{
		makanan();
	}
	else if(menu1 == 2)
	{
		minuman();
	}
	
}

void karyawan()
{
	int karyawan;
	string menu;
	
	system("cls");
	
	cout<<"******************************************************* KARYAWAN ******************************************************"<<endl<<endl;
	cout<<"                                                 1. Hafizhan De Mayerz"<<endl;
	cout<<"                                                 2. Abi Dzar Makasau"<<endl;
	cout<<"                                                 3. Nadya Rahma"<<endl<< endl;
	cout<<"                                                 Pilih karyawan [1/2/3] = ";
	cin>>karyawan;
	cin.ignore();
	
	switch(karyawan)
    {
    case 1 :
        cout<< endl<< endl;
        cout<<"                                                Nama Lengkap = Hafizhan De Mayerz"<<endl;
        cout<<"                                                Nomor ID     = 00020012345"<<endl;
        cout<<"                                                Jabatan      = Manager Perusahaan"<<endl;
        break;
    case 2 :
       cout<< endl<< endl;
       cout<<"                                                Nama Lengkap = Abi Dzar Makasau"<<endl;
       cout<<"                                                Nomor ID     = 00033212345"<<endl;
       cout<<"                                                Divisi	     = 86"<<endl;
       cout<<"                                                Jabatan      = Ketua Divisi"<<endl;
       break;
   case 3 :
       cout<< endl<< endl;
       cout<<"                                                Nama Lengkap = Nadya Rahma"<<endl;
       cout<<"                                                Nomor ID     = 00030812345"<<endl;
       cout<<"                                                Divisi	     = 8"<<endl;
       cout<<"                                                Jabatan      = Manager Divisi"<<endl;
       break;
   }
   
   cout<< endl<< endl<< endl;
   cout<<"Kembali (Ya/Tidak) = ";
   cin>> menu;
   cin.ignore();
   
   if(menu=="ya"||menu=="Ya"||menu=="YA")
   {
       menuhh();
   }
   else(menu=="Tidak"||menu=="tidak");
   {
     system("cls");
 }
}
void menuhh()
{
	int menu;
	
	system("cls");
	
	cout<<"-------------------------------------------------WELCOME TO MINI MARKET-------------------------------------------------"<< endl<< endl<< endl;
	
	cout<<"                                          SILAHKAN PILIH MENU YANG DIINGINKAN ! "<< endl<<endl;
	cout<<"                                          1. PEMBELIAN"<< endl;
	cout<<"                                          2. INFO KARYAWAN"<< endl<< endl;
	cout<<"                                          PILIHAN ANDA [1/2] = ";
	cin>> menu;
	cin.ignore();
	
	if(menu == 1)
	{
		beli();
	} 
	else if(menu == 2)
	{
		karyawan();
	}
	else
	{
		cout<<"Perintah tidak diketahui";
	}
	
}
main()
{
	menuhh();		
}
C++

Program ini dapat diubah dan disesuaikan sesuai dengan kebutuhan dan fitur yang diinginkan dalam program minimarket yang sebenarnya.