Certainly! Here's an example of how you can solve the equation in both Python and Pascal:
### Python:
```python
from sympy import symbols, Eq, solve
def solve_equation():
# Get the equation input from the user
equation_str = input("Enter the equation: ")
# Define the variable x
x = symbols('x')
try:
# Parse and solve the equation
equation = Eq(eval(equation_str), 0)
solution = solve(equation, x)
# Display the solution
print(f"Solution: x = {solution}")
except Exception as e:
# Handle any errors in solving the equation
print(f"Error: {e}")
# Call the function to solve the equation
solve_equation()
```
### Pascal:
```pascal
program EquationSolver;
uses
sysutils, math;
var
equationInput: string;
x, solution: real;
begin
// Get the equation input from the user
write('Enter the equation: ');
readln(equationInput);
try
// Parse and solve the equation
x := math.NaN;
solution := strtofloat(equationInput); // Replace this with your equation parsing logic
// Display the solution
writeln('Solution: x = ', solution:0:2);
except
on E: Exception do
begin
// Handle any errors in solving the equation
writeln('Error: ', E.Message);
end;
end;
end.
```
Please note that in the Pascal example, you'll need to replace the `strtofloat(equationInput)` line with your own logic to parse and solve the equation. Pascal is a compiled language, so you'll need to use a Pascal compiler to run the program.