Program C++ OOP/PBO

//—————————————————————————

#include <vcl.h>
#include<iostream.h>
#include<conio.h>
#pragma hdrstop

//—————————————————————————

class tkotak
{
private:
double pj ;
double lb;
public:
void SetUkuran();
double Keliling();
double Luas();
double GetPanjang();
double GetLebar();
};
void tkotak::SetUkuran()
{
cout<<"Masukkan Panjang : ";cin>>pj;
cout<<"\n";
cout<<"Masukkan Lebar : ";cin>>lb;
};
double tkotak::Keliling()
{
return 2*(pj+lb);
}
double tkotak::Luas()
{
return pj*lb;
}
double tkotak::GetPanjang()
{
return pj;
}
double tkotak::GetLebar()
{
return lb;
}
int main()
{
tkotak kotak;
kotak.SetUkuran();
int count;
cout<<"\n";
cout<<"Keliling : "<<kotak.Keliling()<<endl;
cout<<"\n";
cout<<"Luas : "<<kotak.Luas()<<endl;
getch();
return 0;
}
//—————————————————————————

 

Output Program

image002

 

Iklan

Tinggalkan Balasan

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

Logo WordPress.com

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

Gambar Twitter

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

Foto Facebook

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

Foto Google+

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

Connecting to %s