Quick actions

cmd+k|ctrl+k

Navigation

Languages

Latihan 13.2 Algoritma Dan Struktur Data

Snippet info

Language

Cpp

Visibility

public

Author

fadhlanr

Created

2026-01-03T05:28:49.907177Z

Updated

2026-01-03T05:29:09.37441Z

#include <iostream>
#define pi 3.14

using namespace std;

void garis() {
    cout<<"==============================\n";
}

void author() {
    garis();
    puts("Nama  : Fadhlan R");
    puts("Email : [email protected]");
}

class tabung {
    private:
        int j,t;
        float v,k;
    public:
        void masukan();
        void keluaran();
};

void tabung::masukan() {
    garis();
    cout<<"Program Menghitung Tabung"<<endl;
    garis();
    cout<<"Masukan Jari2  : <input>";cin>>j; cout<<endl;
    cout<<"Masukan Tinggi : <input>";cin>>t; cout<<endl;
    /*
    Rumus menghitung volume tabung
    volume = ( phi x jari x jari ) x tinggi
    */
    v = (pi*j*j)*t;

    /*
    Rumus menghitung keliling tabung
    keliling = ( 2 x ( phi x jari x 2 ) + t
    */
    k=(2*(pi*j*2))+t;
    garis();
}

void tabung::keluaran() {
    cout<<"Volume dari tabung adalah    :"<<printf("%.2f\n",v);
    cout<<"Keliling dari tabung adalah :"<<printf("%.2f\n",k);
}

int main() {
    tabung tabung_obj;
    tabung_obj.masukan();
    tabung_obj.keluaran();
    author();
    return 0;
}
INFO