#include <iostream>
....
Rectangle r;
Point xny;
Asking user for info
....
// I am trying to display the x and y... but it show x:0 and y:0
//Display the x and y coordinates
cout <<"X: " << xny.x <<" " << "Y: " << xny.y << endl;
return 0;
}
Point findarea (Rectangle r)
{
constint midpoint_x = ( r.uppper_left.x + r.lower_right.x ) / 2;
constint midpoint_y = ( r.uppper_left.y + r.lower_right.y ) / 2;
const Point its_center = { midpoint_x, midpoint_y } ;
return its_center;
}
#include <iostream>
using namespace std;
struct Point
{
int x;
int y;
};
struct Rectangle
{
Point uppper_left;
Point lower_right;
};
Point findarea (Rectangle r);
int main ()
{
//remane the Rectangle to r
Rectangle r;
Point xny;
//Welcome the user to program
cout <<"Welcome" << endl;
//Ask the user for information
cout <<"What is the upper left coordinate do you like to input" << endl;;
cin >> r.upawdadpper_left.x >> r.uppper_left.y;
cout <<"What is the lower right coordinate do you like to input" << endl;
cin >> r.lower_right.x >> r.lower_right.y;
if (r.uppper_left.y > r.lower_right.y)
{
cout <<"Error" << endl;
cout <<"The upper right should be bigger than lower left"<< endl;
if (r.uppper_left.y == r.lower_right.y)
{
cout <<"Error" << endl;
cout <<"Your upper left y cannot be same as lower right" << endl;
cout <<"It will create a horizontal line"<< endl;
}
}
//Display the x and y coordinates
cout <<"X: " << xny.x <<" " << "Y: " << xny.y << endl;
return 0;
}
Point findarea (Rectangle r)
{
const int midpoint_x = ( r.uppper_left.x + r.lower_right.x ) / 2;
const int midpoint_y = ( r.uppper_left.y + r.lower_right.y ) / 2;
const Point its_center = { midpoint_x, midpoint_y } ;
return its_center;
}