Question: In C# Create a program named FindSquareRoot that finds the square root of a users input value. The Math class contains a static method named
In C#
Create a program named FindSquareRoot that finds the square root of a users input value. The Math class contains a static method named Sqrt() that accepts a double and returns parameters square root. If the users entry cannot be converted to a double, display an appropriate message and set the square root value to 0. To do so, use Convert.ToDouble() method, which may throw a FormatException. Handle that in the catch block. Otherwise, test the input numbers value. If it is negative, throw a new ApplicationException to which you pass the message Number cannot be negative, and again set the sqrt to 0. If the input value is a double and is non negative, pass it to the Math.Sqrt() method and display
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
