Question 2: (50 pts) Newton-Raphson Square Root Calculation Objective: Develop a C++ class that calculates the square root of a given number using the
Question 2: (50 pts) Newton-Raphson Square Root Calculation Objective: Develop a C++ class that calculates the square root of a given number using the Newton- Raphson method. Instructions: 1- Create a C++ class named SquareRoot Calculator with the following public member functions: double calculateSquareRoot(double number): This function takes a number as input and calculates the square root using the Newton-Raphson method. Return the calculated square root. 2- Implement the Newton-Raphson formula for calculating the square root: Initialize an initial guess for the square root (e.g., 1.0). Iterate using the formula: guess=0.5* (guess + number/guess) until the difference between the guess and the previous guess is very small (e.g., less than 1e-6). 3- In the main function, demonstrate the usage of the SquareRoot Calculator class by: Creating an instance of the class. Taking user input for the number whose square root needs to be calculated. Using the calculateSquareRoot function to calculate and display the square root. Sample Output: Enter a number: 26 Square root using Newton-Raphson method: 5.09902 Process exited after 4.25 seconds with return value 0 Press any key to continue.
Step by Step Solution
3.46 Rating (162 Votes )
There are 3 Steps involved in it
Step: 1
1 Class Creation Define a class named SquareRootCalculator C include class SquareRootCalculator publ...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