#include <iostream>
using namespace std;
// Structure to hold coordinate data
struct Coordinate {
double x;
double y;
};
int main() {
double a1, b1, a2, b2;
while (true) {
// Input parameters for the first line
cout << "Input the a and b parameters for the first line: \n";
cin >> a1 >> b1;
// Input parameters for the second line
cout << "Input the a and b parameters for the second line:\n ";
cin >> a2 >> b2;
// Check if the slopes are equal
if (a1 == a2) {
cout << "The slopes of the lines are equal. Please re-enter all parameter values.\n" << endl;
} else {
break; // Exit the loop if the slopes are not equal
}
}
// Calculate the point of intersection
Coordinate intersection;
intersection.x = (b2 - b1) / (a1 - a2);
intersection.y = a1 * intersection.x + b1;
// Display the intersection coordinates
cout << "The intersection coordinates are: (" << intersection.x << ", " << intersection.y << ")" << endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: