#include <iostream>
#include <conio.h>
using namespace std;
class trapesium {
public:
float a,b,t;
int luas(){
return (((a+b)/2)*t);
}
};
int main(int argc, char** argv){
trapesium x;
cout<<"Menghitung Luas Trapesium"<<endl;
cout<<"Sisi Bawah : ";cin>>x.a;
cout<<"Sisi Atas : ";cin>>x.b;
cout<<"Tinggi : ";cin>>x.t;
cout<<"Luas : "<<x.luas()<<endl;
return 0;
}
2. Keliling Belahketupat
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class Belahketupat{
public:
int s;
int keliling(){
return((4*s));
}
};
int main(int argc, char** argv) {
Belahketupat tupat;
int z, keliling;
cout<<"Masukan sisi : ";cin>>z;
tupat.s=z;
cout<<"Keliling : "<<tupat.keliling();
return 0;
}
3. Program Volume Balok
#include <iostream>
using namespace std;int main ()
{
int p, l, t, volume;
{
cout<<"Menghitung Volume Balok\n";
cout<<"Masukkan Nilai P : ";
cin>>p;
cout<<"Masukkan Nilai l : ";
cin>>l;
cout<<"Masukkan Nilai t : ";
cin>>t;
volume=p*l*t;
cout<<"Volume : "<<volume<<endl;
}
}
Tidak ada komentar:
Posting Komentar