PROGRAM (1)
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class CRectangle {
float x, y;
public:
void set_values (float,float);
float area (void) {return (x*y);}
};
void CRectangle::set_values (float a, float b) {
x = a;
y = b;
}
int main(int argc, char** argv) {
CRectangle rect;
float x,y;
cout<<"MENCARI LUAS PERSEGI PANJANG";
cout<<endl<<endl;
cout<<"Panjang area = ";cin>>x;
cout<<endl;
cout<<"Lebar area = ";cin>>y;
cout<<endl;
rect.set_values (x,y);
cout <<"LUAS PERSEGI PANJANG = "<< rect.area();
return 0;
}
Tidak ada komentar:
Posting Komentar