Menghitung Volume Tabung, Kubus, Bola – Class

#include <cstdlib>
#include <iostream>

using namespace std;

class Volume{
private:
float volume_tabung (float phi, float r, float t);
float volume_kubus (float s);
float volume_bola (float phi, float r);

public:
Volume(){
cout<<“Menghitung Volume Bangun”<<endl;

}
~Volume(){

cout<<“Menghitung Volume dihancurkan”<<endl;
}
void input(){
float phi=3.14;
float r,t,s;
cout<<“1. Menghitung Volume Tabung”<<endl;
cout<<” Masukan jari-jari = “;
cin>>r;
cout<<” Masukan tinggi = “;
cin>>t;
cout<<“2. Menghitung Volume Kubus”<<endl;
cout<<” Masukan sisi kubus = “;
cin>>s;
cout<<“3. Menghitung Volume Bola”<<endl;
cout<<” Masukan jari-jari =”;
cin>>r;
}
void volume(){
float phi = 3.14;
float r,t,s,volume_tabung,volume_kubus,volume_bola;
volume_tabung = phi*r*r*t;
volume_kubus = s*s*s;
volume_bola = 1.333333*phi*r*r*r;
}
void output(){
float phi = 3.14;
float r,t,s,volume_tabung,volume_kubus,volume_bola;
cout<<” Volume Tabung = “<<volume_tabung<<endl;
cout<<” Volume Kubus = “<<volume_kubus<<endl;
cout<<” Volume Bola = “<<volume_bola<<endl;
}

};

int main(){
Volume a;
a.input();
a.volume();
a.output();

system(“PAUSE”);
return EXIT_SUCCESS;
}

About these ads
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logout / Ubah )

Twitter picture

You are commenting using your Twitter account. Logout / Ubah )

Facebook photo

You are commenting using your Facebook account. Logout / Ubah )

Google+ photo

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Ikuti

Get every new post delivered to your Inbox.

%d bloggers like this: