Kamis, 10 November 2011

titik tenah

#include <iostream.h>
#include <conio.h>

class goleeki {
friend istream& operator >> (istream&, goleeki&);
friend ostream& operator << (ostream&, const goleeki&);

public:
goleeki();
void hitung(){
     a =(x1+x2)/2;
     b =(y1+y2)/2;
};
private:
    float x1,y1,x2,y2;
    float a,b;
};

goleeki::goleeki(){
cout << "goleeki titik tengah karo titik A(x1,y1) dan B(x2,y2)\n" << endl;
}
istream& operator >>(istream& cin, goleeki& mlebu){
   cout << "Bijine titik A " <<endl;
   cout << "Mlebu biji x1 : ";   cin >> mlebu.x1;
   cout << "Mlebu biji y1 : ";   cin >> mlebu.y1;
   cout << "Bijine titik B " <<endl;
   cout << "Mlebu biji x2 : ";   cin >> mlebu.x2;
   cout << "Mlebu biji y2 : ";   cin >> mlebu.y2;
   cout<<endl;

return cin;
}
ostream& operator << (ostream& out, const goleeki& metu)
{
  out<< "titik tengahe inggih menika : " <<endl;
  out<< "\t" << "(XT,YT)" <<endl;
  out<< "\t" << "(" << metu.a << "," << metu.b << ")" <<endl;

return out;
}

void main(){
goleeki titik;
cin>>titik;
titik.hitung();
cout<<titik;



getch ();
}