menu

Tampilkan postingan dengan label BAB 4. Tampilkan semua postingan
Tampilkan postingan dengan label BAB 4. Tampilkan semua postingan

Sabtu, 09 April 2016

Algoritma dan program Menentukan Uang Lembur Pegawai

#include <iostream>


using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
   
    int bulan;
   
    cout << " ___ UANG LEMBUR 2016 ___ " <<endl;
    cout << " ======================== " <<endl<<endl;
    cout << " Uang lembur yang diperoleh pada bulan ke- "; cin >> bulan;
    cout << endl;
    cout << " =================================================== " << endl;
    switch(bulan)
    {
        case 1:
            cout << " --- Januari --- "<<endl;
            int gaji, jam1, jam2;
            float total;
           
            jam1 = 16*8;
            jam2 = 5*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Januari (31 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;   
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;   
        case 2:
            cout << " --- Februari --- "<<endl;
                       
            jam1 = 17*8;
            jam2 = 4*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Februari (29 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;   
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;
        case 3:
            cout << " --- Maret --- "<<endl;
                       
            jam1 = 19*8;
            jam2 = 4*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Maret (31 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;   
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;
        case 4:
            cout << " --- April --- "<<endl;
                       
            jam1 = 16*8;
            jam2 = 5*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan April (30 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;   
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;
        case 5:
            cout << " --- Mei --- "<<endl;
           
            jam1 = 18*8;
            jam2 = 4*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Mei (31 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;   
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;
        case 6:
            cout << " --- Juni --- "<<endl;
           
            jam1 = 18*8;
            jam2 = 4*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Juni (30 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;   
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;
        case 7:
            cout << " --- Juli --- "<<endl;
           
            jam1 = 16*8;
            jam2 = 5*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Juli (31 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;   
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;
        case 8:
            cout << " --- Agustus --- "<<endl;
                       
            jam1 = 19*8;
            jam2 = 4*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Agustus (31 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;
        case 9:
            cout << " --- September --- "<<endl;
                       
            jam1 = 17*8;
            jam2 = 5*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan September (30 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }
        break;
        case 10:
            cout << " --- Oktober --- "<<endl;
                       
            jam1 = 17*8;
            jam2 = 4*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Oktober (31 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }
        break;
        case 11:
            cout << " --- November --- "<<endl;
                       
            jam1 = 18*8;
            jam2 = 4*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan November (30 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }                                   
        break;
        case 12:
            cout << " --- Desember --- "<<endl;
                       
            jam1 = 17*8;
            jam2 = 5*3;
            total= jam1+jam2;
            cout << " Jam Kerja Selama Bulan Agustus (31 Hari) adalah : "<< total <<" jam"<< endl;
            if (total > 30)
            {
                gaji=(total/5)*30000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;
            }
            else
            {
                gaji=total*4000;
                cout << " Uang Lembur Yang Diperoleh Rp."<<gaji<<endl;   
            }   
        break;
    }
   
   
    return 0;
}

Algoritma dan program Konversi Nilai ke Nilai Huruf

#include <iostream>

using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
    int nilai;
   
    cout << " Menentukan Nilai Angka " << endl << endl;
   
    cout << " Masukan Nilai Angka : "; cin >> nilai;
    cout << endl;
   
    if ( nilai <= 100 && nilai >= 91)
    {
        cout << nilai << " Nilai hurufnya adalah A " << endl;
    }
    if ( nilai <= 90 && nilai >= 81)
    {
        cout << nilai << " Nilai hurufnya adalah B " << endl;
    }
    if ( nilai <= 80 && nilai >= 71)
    {
        cout << nilai << " Nilai hurufnya adalah C " << endl;
    }
    if ( nilai <= 70 && nilai >= 61)
    {
        cout << nilai << " Nilai hurufnya adalah D " << endl;
    }
    if ( nilai <= 60 && nilai >= 0)
    {
        cout << nilai << " Nilai hurufnya adalah E " << endl;
    }
   
   
    return 0;
}

Algoritma dan program Menkonversi bilangan menjadi kode ASCII

#include <iostream>

using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
   
    int n;
   
    cout << " ---Konversi Bilangan Menjadi Kode ASCII--- " << endl;
    cout << " __________________________________________ " << endl;
   
    cout << " Masukan Bilangan (maks. 255) : "; cin >> n;
    cout << " ASCII dari bilangan tersebut "<< n <<" adalah : "<<(char)n<<endl;
   
   
    return 0;
}

Algoritma dan program Menampilkan Tanggal pada Bulan dan Tahun Tertentu

#include <iostream>
#include <conio.h>

using namespace std;

int main(){
   
    int tahun, bulan,bil;

    cout << " Masukkan Tahun    : "; cin >> tahun;
    cout << " Masukkan Bulan ke : "; cin >> bulan;

    switch (bulan)
    {
        case 2:
            if ((tahun%100==0)||(tahun%100!=0)&&(tahun%400==0))
            {
                for(int i=1; i<=29; i++)
                {
                cout<<i<<" ";
                }
            }
            else
            {
                for(int i=1; i<=28; i++)
                {
                    cout<<i<<" ";
                }
            }
        break;

        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
        {
            for(int i=1; i<=31; i++)
            {
                cout<<i<<" ";
            }
        }
        break;

        case 4:
        case 6:
        case 9:
        case 11:
        {
            for(int i=1; i<=30; i++)
            {
                cout<<i<<" ";
            }
        }
        break;
        default:
        cout<<"salah kode bulan\n";
    }
   
getch();
}

raptor :

Menkonversi nilai angka ke nilai huruf


Algoritma dan program kasus 2

#include <iostream>
#include <math.h>
#include <conio.h>

using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

class Akar {
    friend ostream& operator<<(ostream&, Akar&);
    friend istream& operator>>(istream&, Akar&);
    public:
    Akar();
    int disk() { return B*B-4*A*C; }
    float akar1() {return (-B+sqrt(disk()))/(2*A); }
    float akar2() {return (-B-sqrt(disk()))/(2*A); }
    void hitung_akar();
    void cetak_disk() {
         cout << "diskriminan = " << disk() << endl; }
    void cetak_akar() {
        cout << "x1 = " << akar1() << endl;
        cout << "x2 = " << akar2() << endl;
    }
private:
    int A, B, C; // input
    float x1, x2; // akar 1 dan akar 2
};
ostream& operator<<(ostream& out, Akar& keluaran) {
    keluaran.cetak_disk();
    if (keluaran.disk() >= 0) keluaran.cetak_akar();
    else out << "Akar imajiner";
    return out;
}
istream& operator>>(istream& in, Akar& masukan) {
    cout << "Koefisien pangkat 2 : "; cin >> masukan.A;
    cout << "Koefisien pangkat 1 : "; cin >> masukan.B;
    cout << "Koefisien pangkat 0 : "; cin >> masukan.C;
return in;
}
Akar::Akar() {
    cout << "Menghitung akar persamaan kuadrat "<<endl<<endl;
}

void Akar::hitung_akar() {
    if (A == 0) {
    cout << "bukan pers. kuadrat.\n";
    cout << "Harga akar = " << -C/B; } else {
    if (disk() > 0) {
        x1 = akar1();
        x2 = akar2();
        }   
    else if (disk() == 0) {
        x1 = akar1();
        x2 = x1;
        }
    }   
}

int main(int argc, char** argv) {
    Akar kasus;
    cin >> kasus;
    kasus.hitung_akar();
    cout << kasus;
    return 0;
}

raptor:

Algoritma dan program mencari bil terbesar