Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

run this code and let me know if there are any syntax errors thank you. import java.util.Scanner; // Import Scanner import java.lang.Math; // Import Math

run this code and let me know if there are any syntax errors thank you.


import java.util.Scanner; // Import Scanner import java.lang.Math; // Import Math

public class Part095SqrtAssignment { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Create a new Scanner System.out.print("Enter a number: "); double x = scanner.nextDouble(); // Read the number from the user

double estimate = 2; double error = 0.0001; double difference = Math.abs(estimate * estimate - x); // Write a while loop to update the estimate and difference while (difference > error) { estimate = (estimate + x / estimate) / 2.0; difference = Math.abs(estimate * estimate - x); }

// Print the estimate and the true square root System.out.println("Estimated square root: " + estimate); System.out.println("True square root: " + Math.sqrt(x)); scanner.close(); // Close the scanner } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials Of Business Communication

Authors: Mary Ellen Guffey, Dana Loewy

11th Edition

1337386499, 9781337386494

More Books

Students also viewed these Algorithms questions

Question

Prove Lagrange's Identity, ||u v||2 = ||u||2||v||2 - (u v)2

Answered: 1 week ago

Question

Explain the value of direct marketing for consumers and sellers.

Answered: 1 week ago

Question

Calculate the missing values for the promissory notes described

Answered: 1 week ago