Wednesday, December 30, 2015

Modifikasi 3 "Program Class Luas Layang-layang C++"

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class layang_layang{
private :
int d1, d2;

public:
int luas(){
return(((d1*d2)*1/2));
}
void kasihnilai(int D1, int D2){
d1=D1;d2=D2;
}
};
int main(int argc, char** argv) {
layang_layang lyg,lyang;
int a,b;
cin>>a>>b;
lyg.kasihnilai(a,b);
lyang.kasihnilai(10,5);
cout<<"Luas 1: "<<lyg.luas()<<endl;;
cout<<"Luas 2: "<<lyang.luas();
return 0;

}//GAM



EmoticonEmoticon