To determine the location of a point on the plane required the initial benchmark. Initial benchmark is made of two number lines that intersect riel perpendicular at the null point, which is a flat (horizontal) and the other upright (vertical). A horizontal line called the X-axis, and a vertical line called the axis Y. Two mutually perpendicular axes is called a Cartesian coordinate system perpendicular or simply coordinate Kartesius.dalam times inni case will make sustu example program that is associated with point atupun cartesian coordinates of two points, we suppose to calculate the distance from the coordinates of two points A ( x1, y1) and B (x2, y2) and this is the shape of his program by using Overloding in C + +;
# include <iostream>
# include <conio.h>
class count {
friend ostream & operator <<(ostream &, & count);
friend istream & operator>> (istream &, & count);
public:
count ();
hitung_jarak void () {distance = ((Y2-Y1) * (Y2-Y1) - (X2-X1) * (X2-X1));}
private:
float X1, X2, Y1, Y2, distance;
};
count:: count () {
court <<"\ t \ tSlamet Islan Al Hidayah" <<endl;
court <<"\ t \ t 10018075" <<endl;
court <<endl;
court <<"Progaram For Calculating distance from two points" <<endl;
court <<endl;
}
istream & operator>> (istream & ins, & mlebu count) {
court <<"Enter the point X1 =";
in>> mlebu.X1;
court <<"Enter the point X2 =";
in>> mlebu.X2;
court <<"Enter the point Y1 =";
in>> mlebu.Y1;
court <<"Enter the point Y2 =";
in>> mlebu.Y2;
return in;
}
ostream & operator <<(ostream & out, count & metu) {
court <<endl;
court <<"Show Total distance =" <<metu.jarak <<endl;
return out;
}
main () {
count x;
cin>> x;
x.hitung_jarak ();
court <<x;
getch ();
return 0;
}
Output :
well something like this was fibonica calculation program in the class overloading. please ditliti again if there are any shortcomings or errors please stay do you comment so I can fix it.
good luck best wishes.
good luck best wishes.
Regards super ..
0 Response to " PROGARAM TO CALCULATE THE DISTANCE OF TWO POINTS "
Post a Comment