Answer to Question #250728 in C++ for hassi

Question #250728

Create a struct point to represent a point in cartesian coordinate system

provide member functions

default constructor

input

output

distance(returns the distance between two point objects, the function takes one object as an argument)

is zero(determines if a point is the center)

midlepoint (computes the middle point of an object from origin and returns the answer in a point object)

is equal to(compare two points)

isGreater than (compares two point in terms of the distance from the center)


1
Expert's answer
2021-10-13T20:38:49-0400
#include <bits/stdc++.h>


using namespace std;
struct Point{
    int x;
    int y;
    Point(){
        
    }
    void distance(Point p){
        cout<<"\nEnter x2: ";
        cin>>p.x;
        cout<<"\nEnter y2: ";
        cin>>p.y;
        double dist= sqrt(pow(p.x - x, 2) +pow(p.y - y, 2) * 1.0);
        cout<<"\nDistance: "<<dist;
    }
    
  
};
void is_equal_to(Point p1, Point p2){
     if(p1.x==p2.x && p1.y==p2.y) 
        cout<<"\nThe two points are equal";
     else
        cout<<"\nThe two points are not equal";
}
void isGreater_than(Point p1, Point p2){
        int a=p1.x+p1.y;
        int b=p2.x+p2.y;
        if(a>b){
            cout<<"\nThe first point is greater.";
        }
        else if(b>a){
            cout<<"\nThe second point is greater.";
        }
        else
            cout<<"\nThe two points are equal.";
}
void isZero(Point p1){
        if(p1.x==0 && p1.y==0)
            cout<<"\nThe point is zero";
        else
            cout<<"\nThe point is not zero";
}
int main()
{
    


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS