Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a php page that prompts user to enter an equation. When the user hits the submit button, the entered equation will be validated and
Write a php page that prompts user to enter an equation. When the user hits the submit button, the entered equation will be validated and evaluated in the same page. If the equation is valid, then it will be evaluated and the result is displayed on the page as shown in the following figure:
Please note the following:
- The entered equation is valid if and only if:
- It is written in the following sequence: a first operand, followed by an operator, and finally a second operand.
- The first operand is an even number greater than or equal 0.
- The second operand is divisible by 5 and greater than or equal 0.
- The operator could be +, -, *, or /
- E.g.) the equation 3+995 is invalid, but 466+45 is valid
- The validation discussed above should be implemented only using regular expressions and the preg_match function.
- If the equation is invalid, the error message Please enter a valid equation is displayed
- JavaScript code is not allowed.
- the value of the input field is kept when the user hits the submit button .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started