Using C#: The function is given a string representing a linear equation with one…
- User
Using C#: The function is given a string representing a linear equation with one unknown. Find the value of x that is a valid solution of the equation. Return the sting x=val. Three outcomes are possible:
x_val is an integer or a float (round x_val to 2 decimals) "Infinite solutions" for situations 0x=0 "No solution" for situations 0x=num, (num != 0) Examples FindX("4x-7=x+11") ➞ "x=6"
FindX("3x=2x+x") ➞ "Infinite solutions"
FindX("3x=3x+2") ➞ "No solution"
FindX("-1-2x=15+x") ➞ "x=-5.33" Notes It is a good exercise for using Regex to find all numbers and coefficients of x. All numbers have at most 3 digits.
using System;
public class Program { public static string FindX(string eq) {
code}}
- Assistant