#include <iostream> #include <cmath> using namespace std; int main() { int w; cout << "Enter value of w: "; cin >> w; while(w < 5) { cout << "Invalid value. Enter w again: "; cin >> w; } int x, y; bool found = false; cout << "Enter point x and y (separate by space): "; cin >> x >> y; if(x >= 0 && y >= 0 && (x + y) <= w) { cout << "The point is on or inside the upper triangle." << endl; found = true; } if(x <= 0 && y <= 0 && (abs(x) + abs(y)) <= w) { cout << "The point is on or inside the lower triangle." << endl; found = true; } if(!found) { cout << "The point is outside of the 2 triangles." << endl; } }
please upvote. Thanks!
Using c++ specific methods: Practice Problem 2 Write a program which obtains an integer w from the user. Assume that the user will always provide a positive number. The quantity w defines the followi...