Instructions Write a program that prompts the user to enter the X and Y coordina
ID: 3841639 • Letter: I
Question
Instructions Write a program that prompts the user to enter the X and Y coordinates for two points on a graph. Once the points are entered, display a graph plotting the positions of the points on the graph Use nested for loops to print either a blank or asterisk in each possible location of the graph Use the if-else decision construct to determine which option to output to the cells of the graph. Use integer variables plx, plY, p2X, and p2Y to hold coordinates of point 1 and point 2. Use a do-while loop to allow the user to enter another set of coordinates. Use the system function call to clear the screen between repetitions of graph point entries Limitations Only positive coordinates will be given. Limit the range of the graph to 9 by 9. CSC CSC by by nter the by 36 or point nter the by space 89 or point 01 23456789 nt ul d you like to plot another pair of points? Cy n) Example Screen Capture 1 Example Screen Capture 2Explanation / Answer
Code:-
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
int p1x,p1y,p2x,p2y;
char check;
while(1){
cout<<"Enter the co-ordinates for point 1";
cin>>p1x;
cin>>p1y;
cout<<"Enter the co-ordinates for point 2"<<endl;
cin>>p2x;
cin>>p2y;
if(p1x<0 || p2x <0 || p1y<0 || p2y<0){
cout<<"WRONG INPURS NO NEGATIVE...PLEASE TRY AGAIN "<<endl;
continue;
}
if((p1x<0 && p1x>9) || (p1y<0 && p1y>9) || (p2x<0 && p2x>9) || (p2y<0 && p2y>9)){
cout<<"WRONG INPURS LIMIT IS WITHIN 0-9...PLEASE TRY AGAIN "<<endl;
continue;
}
for(int i=9;i>=0;i--){
cout<<i;
for(int j=0;j<10;j++){
if(j==p1x && i==p1y){
cout<<"*";
}
else{
if(j==p2x && i==p2y){
cout<<"+";
}
else{
cout<<" ";
}
}
}
cout<<endl;
}
cout<<" ";
for(int j=0;j<10;j++){
cout<<j;
}
cout<<endl<<"Do you want to try to new set of co-ordinates? (Y/N)?";
cin>>check;
if(check=='Y'){
system("cls");
}
else
break;
}
return 0;
}