Untitled

mail@pastecode.io avatar
unknown
plain_text
15 days ago
5.2 kB
7
Indexable
Never
// Online C++ compiler to run C++ program online
#include <iostream>

int main()
{
    int countFirst, countSecond, equal;
    std::string aritmatic;
    std::cout << "\n\n========================\n\n";
    std::cout << "Penjumlahan Bilangan\n\n";

    std::cout << "Tolong masukkan Bilangan Pertama ";
    std::cin >> countFirst;
    std::cout << "Tolong pilih operator ";
    std::cin >> aritmatic;
    std::cout << "Tolong masukkan Bilangan Pertama ";
    std::cin >> countSecond;

    if (aritmatic == "+")
    {
        equal = countFirst + countSecond;
    }
    else if (aritmatic == "-")
    {
        equal = countFirst - countSecond;
    }
    else if (aritmatic == "/")
    {
        equal = countFirst / countSecond;
    }
    else if (aritmatic == "*")
    {
        equal = countFirst * countSecond;
    }
    std::cout << "Hasil Bilangan " << equal;

    std::cout << "\n\n========================\n\n";

    std::cout << "Luas Lingkaran\n\n";

    float phi = 3.14;
    int r;
    float equalCircle;

    std::cout << "Tolong masukkan jari-jari ";
    std::cin >> r;

    std::cout << "\nDiameter adalah " << r * 2;

    equalCircle = phi * r * 2;

    std::cout << "\nKeliling lingkaran adalah " << equalCircle;

    std::cout << "\n\n========================\n\n";

    std::cout << "Luas Segitiga\n\n";
    int a, t;
    float equalTriangle;

    std::cout << "Tolong masukkan alas ";
    std::cin >> a;
    std::cout << "Tolong masukkan tinggi ";
    std::cin >> t;

    equalTriangle = 0.5 * a * t;

    std::cout << "\nLuas Segitiga adalah " << equalTriangle;

    std::cout << "\n\n========================\n\n";

    std::cout << "Luas Persegi Panjang\n\n";
    int p, l;
    float equalPersegiPanjang;

    std::cout << "Tolong masukkan panjang ";
    std::cin >> p;
    std::cout << "Tolong masukkan lebar ";
    std::cin >> l;

    equalPersegiPanjang = p * l;

    std::cout << "\nLuas Persegi Panjang adalah " << equalPersegiPanjang;

    std::cout << "\n\n========================\n\n";

    std::cout << "Perulangan For Bintang\n\n";

    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if (j < i)
            {
                std::cout << "*";
            }
        }
        std::cout << "\n";
    }

    std::cout << "\n\n========================\n\n";

    std::cout << "Perulangan For Segitiga\n\n";

    for (int i = 0; i <= 10; i++)
    {
        for (int j = 0; j <= 10; j++)
        {
            std::cout << " ";
        }
        for (int j = i; j <= 10; j++)
        {
            std::cout << " ";
        }
        for (int j = 1; j <= i; j++)
        {
            std::cout << "*";
        }
        for (int j = 1; j < i; j++)
        {
            std::cout << "*";
        }
        std::cout << "\n";
    }

    std::cout << "\n\n========================\n\n";

    std::cout << "Data Bilangan\n\n";

    for (int i = 1; i <= 100; i++)
    {
        if (i % 10 == 0)
        {
            std::cout << i << " ";
            std::cout << "\n";
        }
        else
        {

            std::cout << i << " ";
        }
    }

    std::cout << "\n\n========================\n\n";

    std::cout << "Segitiga Angka\n\n";

    for (int i = 1; i <= 10; i++)
    {

        // std::cout << "\n";
        for (int j = 1; j <= 10 - i; j++)
        {
            std::cout << j << " ";
        }
        std::cout << "\n";
    }
    for (int i = 1; i <= 10; i++)
    {

        // std::cout << "\n";
        for (int j = 1; j <= 10; j++)
        {

            if (j < i)
            {
                std::cout << j << " ";
            }
        }
        std::cout << "\n";
    }

    std::cout << "\n\n========================\n\n";

    std::cout << "Kotak Angka\n\n";

    for (int i = 1; i <= 10; i++)
    {

        // std::cout << "\n";
        for (int j = 1; j <= 10; j++)
        {
            std::cout << i << " ";
        }
        std::cout << "\n";
    }

    std::cout << "\n\n========================\n\n";

    std::cout << "Do While Loop\n\n";

    int countData = 0;

    do
    {
        std::cout << "angka = " << countData << "\n";
        countData += 1;
    } while (countData < 10);

    std::cout << "\n\n========================\n\n";

    std::cout << "KASIR\n\n";
    std::cout << "Selamat Datang\n\n";
    std::cout << "Menu Makanan\n";
    std::cout << "1. Nasi Goreng : Rp. 15.000\n";
    std::cout << "2. Magelangan : Rp. 16.000\n";
    std::cout << "Menu Minuman\n";
    std::cout << "1. Es Jeruk : Rp. 3.000\n";
    std::cout << "2. Es Teh : Rp. 4.000\n";

    int makanan, minuman, jmlMakanan, jmlMinuman, equalKasir;

    std::cout << "Silahkan Pilih Makanan";
    std::cin >> makanan;
    std::cout << "Silahkan Pilih Minuman";
    std::cin >> minuman;

    if (makanan == 1)
    {
        jmlMakanan = 15 * 1000;
    }
    else if (makanan == 2)
    {
        jmlMakanan = 16 * 1000;
    }
    if (minuman == 1)
    {
        jmlMinuman = 3 * 1000;
    }
    else if (minuman == 2)
    {
        jmlMinuman = 4 * 1000;
    }

    equalKasir = jmlMakanan + jmlMinuman;

    std::cout << "\nTotal Tagihan anda adalah\n"
              << equalKasir;

    return 0;
}
Leave a Comment