Question: Java Programing /********************************************* **************************/ /* PROBLEM 1 */ Write a program that takes an input n, then using the Baylonian algorithm given below iterate through



/********************************************* **************************/ /* PROBLEM 1 */ Write a program that takes an input n, then using the Baylonian algorithm given below iterate through it(loops), until the guess is within 1% of the previous guess. Then ouputs the answer as a double to within two decimal places. The result should be accurate no matter the size of the value of n inputted. The Baylonian algorithm to compute the square root of a number n is as follows: 1) Make a guess at the answer (you pick n/2 as your initial guess) 2) Computer = n/guess 3) Set guess = (guess + r) /2 4) Go back to step 2 until the last two guess values are the same. / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ************************** / /* PROBLEM 3 */ a) What is the output of the following? b) Comment the code, there should a block comment towards what the segment of code does, and then also comment each line c) How would the println statements look if they were converted to printf? int n, limit = 10; for (n = 1; n = 1; m--) System.out.println(n + "times " + m + " = " + n*m) ; * ** ** * ** ** ** * * * *** ** * ** ** * / /* PROBLEM 5 */ a) What is the output produced by the following? (Type out the answer) b) Comment the code, there should a block comment towards what the segment of code does, and then also comment each line int number = 10; while(number>0) number = number -2; if (number == 4) System.out.println(number); System.out.println("The end."); /* * ** * * ** * * ** * * ** * ** * * ** * * ** * * ** ** * * ** * * ** ** * * **************************/ /* PROBLEM 6 */ Write the print and printf statements that would produce the following output. You will use your name (First and Last) that is stored in a string variable. Within the method, use the print statement first and then the printf statement
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
