Quick actions

cmd+k|ctrl+k

Navigation

Languages

Tugas Algoritma 13.2

Snippet info

Language

Cpp

Visibility

public

Author

rosdianafitriyani

Created

2025-01-02T06:06:58.474728Z

Updated

2025-01-02T06:18:55.265309Z

#include <iostream>
#define pi 3.14

using namespace std;

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

void author() {
    garis();
    puts("Nama  : Rosdiana Fitriyani");
    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("%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