Quick actions

cmd+k|ctrl+k

Navigation

Languages

Algoritma13.2

Snippet info

Language

Cpp

Visibility

public

Author

nurizzatisql

Created

2024-12-28T10:15:23.366177Z

Updated

2024-12-28T10:15:23.366177Z

#include <iostream>
#define pi 3.14

using namespace std;

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

void author() {
    garis();
    puts("Nama  : Nur Izzati Istiqlal");
    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 jar 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("%8.2f\n",v);
    cout<<"Keliling dari tabung adalah : ";printf("%8.2f\n",k);
} 

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