square Root Approximation Calculations Find square root approximation of what number 55 ERROR

IN JAVA PLEASE HELP IM SO CONFUSED I THINK I GOT METHOD ONE DOWN BUT THE REST IS so confusing You are not allowed to use break or return statements to exit from any loop. So all loops must exit only via their test condition evaluating to false.Things to notice about this formula: num will always be the same 𝒔𝒒𝒓𝑹𝒐𝒐𝒕𝐧 is the previous value that was calculated 𝒔𝒒𝒓𝑹𝒐𝒐𝒕𝐧+𝟏 is the current value being calculated For example, the first four square root approximation values that would be calculated for the number 36: π’”π’’π’“π‘Ήπ’π’π’•πŸ = 36 / 2.0 = 18.0 π’”π’’π’“π‘Ήπ’π’π’•πŸ = (18.0 + 36.0/18.0) / 2.0 = 20.0 / 2.0 = 10.0 π’”π’’π’“π‘Ήπ’π’π’•πŸ‘ = (10.0 + 36.0/10.0) / 2.0 = 13.6 / 2.0 = 6.8 π’”π’’π’“π‘Ήπ’π’π’•πŸ’ = (6.8 + 36.0/6.8) / 2.0 = 12.09411765 / 2.0 = 6.047058824 As you can see, even after just 4 repetitions, the result is getting pretty close to 6! You will write a program to approximate the square root of a number, using this formula, and applying it two different ways with user input error checking. NOTE: You cannot use the built-in Java Math.sqrt(x) method anywhere in your code.At least one boolean variable’s value to make a decision (where appropriate) At least one while loop (where appropriate) At least one do-while loop (where appropriate) At least one for loop (where appropriate)First write a method definition for method 1, placing the code after the definition for the main() method. Method 1 will read, validate, and return a floating point (double) value entered by the user, ensuring that it is positive and non-zero. The method will:Have a descriptive method name, including a verb that describes its actions Have two parameters: o a Scanner to read input from the keyboardExample: public static returnType someMethod (Scanner scnr) When this method is called, the argument will be the main() method Scanner object a String description, describing what is being read (to be used as the prompt) Until the user enters valid input (i.e. a positive and non-zero number), use the String parameter to prompt for and read the input , issuing this error message for invalid inputs: ERROR! Input must be greater than 0. Please try again.Return a valid positive and non-zero double value.Define necessary variables, including a Scanner variable to read input from the keyboard. Display this program description, followed by a blank line: Square Root Approximation Calculations Call method 1 to read and save the number whose square root will be approximated, using the following, as the prompt argument: Find square root approximation of what number? Next, write the method definition for method 2, named calcApproxSqrRoot(). Place the code after the definition for the method 1. The method will continuously apply the formula from page 1, until the calculation is within a certain acceptable range.Keep calculating a new sqrRoot approximation until multiplying the approximation by itself results in a number that is within the acceptable range of the original number. Using the example of finding the approximate square root of 36, from page 1, suppose the acceptable range was 1.0: The third approximation is 6.8 6.8 x 6.8 = 46.24, which is NOT within the acceptable range of 1.0 of 36. So continue. The fourth approximation is 6.047058824 6.047058824 x 6.047058824 = 36.56692042, which is within 1.0 of 36. So stop. HINT: You can use Java’s built-in absolute value method, e.g., Math.abs()Have two double parameters: the double number whose square root will be approximated the double acceptable range Display one blank line, and then display the values the method will use, as follows, (do not use printf(), because we do not want to format the numeric values in this output):APPROXIMATION will estimate the square root of 36.0. The estimation will produce a square within 0.1 of 36.0. Approximations will be displayed after every calculation.At the top of the method, define a local double type variable to hold the square root approximation. Remember to also define any other local variables needed at the top of the method. Initialize your variable to the value for π’”π’’π’“π‘Ήπ’π’π’•πŸ and display one blank line followed by the value rounded to 10 decimal places, as shown belowApproximation 1: 18.0000000000Within a loop, until the square root approximation is within the acceptable range (hint: multiply the approximation by itself to see how close it is the actual squared value) o Apply the formula to calculate a more accurate value for the square root approximation o Display the calculated square root approximation to 10 decimal placesApproximation 1: 18.0000000000 Approximation 2: 10.0000000000 Approximation 3: 6.8000000000 Approximation 4: 6.0470588235 Approximation 5: 6.0001831083After the loop exits: o Return the final value of the square root approximation, from the last calculationFirst display a blank line. Determine which technique to use for calculating the approximation, using this menu and prompt:Approximation methods 1 - Approximate to within a specified range 2 - Approximate a fixed number of times Enter your choice: Add a decision statement to call the correct method When 1 is chosen: o Call method 1 a second time to read and save the acceptable range for the approximation, using the following, as the prompt argument: Acceptable range for the approximation? NOTE: Calling the same method again works because both user inputs should be positive and non-zero. The only difference between the two calls will be the prompt that is passed in as the argument for the second parameter, and what variable will be used to store the returned value. o Call method 2, supplying the needed arguments in the call. When 2 is chosen: o FOR NOW, do nothing Display another blank line, followed by the result returned from the method call, as shown below. o Do not use printf() for the FIRST line (do not want to format the number) o Format the positive and negative results rounded to 10 decimal places, using a width of 20 and the printf() + flag that causes signs to show. Example for square root of 36 with an acceptable range of 0.1:Approximate square roots of 36.0 are: -6.0001831083+6.0001831083 Next, write the method definition for method 3, an overloaded method with the same name, calcApproxSqrRoot(). Place the code after the definition for the method 2. This method will apply the formula from page 1 a fixed number of times, displaying approximation values at specified intervals. So it will display the value of every Xth square root approximation, with the value of X specified by the user.For example, if the user wants to display every 3rd square root approximation, then the program should display the results after the 3rd, 6th, 9th, etc. square root approximation has been calculatedAlthough overloaded methods have the same method name, they must have different parameters (parameter types, or the number of parameters). Therefore, this method will: Have three parameters, one double and two integers: o the double number whose square root will be approximated o the integer number of times to apply the approximation formula o the integer display intervalDisplay one blank line, and then display the values the method will use, as follows: APPROXIMATION will estimate the square root of 11111.1, by applying the approximation formula 7 times. Approximations will be displayed after every 3 calculation(s).Again, at the top of the method, define a local double type variable to hold the approximate value of the square root, and initialize it to the value for π’”π’’π’“π‘Ήπ’π’π’•πŸ o Remember to also define any other local variables needed at the top of the method.Display one blank line. When required by the display interval, display the first approximation rounded to 10 decimal places. Within a loop, until the approximation has been calculated the correct number of times: o Apply the formula to calculate a more accurate value for the square root approximation o If the calculation falls on a display interval, display the approximation count and the square root approximation to 10 decimal places. After the loop exits return the final value of the square root approximation, from the last calculation (even if it was not displayed). Add the following code to your decision statement action for when 2 is chosen o Call method 1 a third time to read the number of times to apply the approximation formula. Pass in the following, as the prompt argument: Number of times to apply the approximation formula?Convert and save the returned value as an integer. o Call method 1 a fourth time to read the display interval. Pass in the following, as the prompt argument: Display approximation after every how many calculations? Again, convert and save the returned value as an integer. o Call method 3, supplying the needed arguments in the call.Approximation 3: 1391.3867802584Approximation 6: 194.4192820682 lines displayed by calcApproxSqrRoot()Approximate square roots of 11111.1 are: lines displayed by main() -125.7847388377 +125.7847388377Add code to error check that the approximation method chosen is valid. Modify the code in the main() method as follows: Add a loop around the code that prompts for the choice and reads the approximation method that repeats until the user input is valid (do not repeat the menu, just the choice prompt). o When the input is not valid, issue the error message. ERROR! Must enter 1 or 2. Please try again. Modify the main() method code to repeat the program, as follows: Display a blank line, and then ask if the user wants to run the program again with the prompt: Run again (y/n)? As long as the user enters β€˜y’ or β€˜Y’ to the question, display 2 blank lines and then loop to run the program again.Be sure to insert the loop so that the previously written code is re-used when the program repeats, and your code does not have duplications. When the user chooses not to run the program again, display: Goodbye!

IN JAVA PLEASE HELP IM SO CONFUSED I THINK I GOT METHOD ONE DOWN BUT THE REST IS so confusing You are not allowed to use break or return statements to exit from any loop. So all loops must exit only via their test condition evaluating to false.Things to notice about this formula: num will always be the same 𝒔𝒒𝒓𝑹𝒐𝒐𝒕𝐧 is the previous value that was calculated 𝒔𝒒𝒓𝑹𝒐𝒐𝒕𝐧+𝟏 is the current value being calculated For example, the first four square root approximation values that would be calculated f

Read More

1 Create a TypeScript program that repeats the values 1 to 100 with the following loop operation

Create a TypeScript program that repeats the values 1 to 100, with the following loop operation: a. The first 10 loops display odd values (1 3 5 7 9) b. The second 10 repetition displays even values (12 14 16 18 20) c. And so on until we get to 100 repetitions. d. Each multiple displays the number of numbers displayed. e. Example output: 10 Repetition 1st : 1 3 5 7 9 -------------------------- Total sum : 25 10 repetitions 2nd: 12 14 16 18 20 -------------------------- Total sum : 80 10 repetitions 3rd : 21 23 … … etc

Create a TypeScript program that repeats the values 1 to 100, with the following loop operation: a. The first 10 loops display odd values (1 3 5 7 9) b. The second 10 repetition displays even values (12 14 16 18 20) c. And so on until we get to 100 repetitions. d. Each multiple displays the number of numbers displayed. e. Example output: 10 Repetition 1st : 1 3 5 7 9 ————————– Total sum : 25 10 repetitions 2nd: 12 14 16 18 20 ————————– T

Read More

Your task is to implement in Python the following adversarial search algorithms refer to lecture

Your task is to implement in Python the following adversarial search algorithms (refer to lecture slides and/or your textbook for details | pseudocode provided below): MiniMax (as specified by the MINIMAX-SEARCH pseudocode below) When the game is complete, your program should display a corresponding message: X WON or O WON TIE X LOST or O LOST MiniMax with alpha-beta pruning (as specified by the ALPHA-BETA-SEARCH pseudocode below), and apply them to play the game of Tic-Tac-Toe (computer). Using any other approach is not going to be accepted. Problem input/command line interface: Your program should: Accept three (3) command line arguments, so your code could be executed with python cs480_P01_AXXXXXXXX.py ALGO FIRST MODE where: - cs480_P01_AXXXXXXXX.py is your python code file name, - ALGO specifies which algorithm the computer player will use: 1 - MiniMax, 2 - MiniMax with alpha-beta pruning, - FIRST specifies who begins the game: X When it is human player's turn, your program should display the following prompt: X's move. What is your move (possible moves at the moment are: | enter 0 to exit the game)? where: is a sorted list of all available moves at the moment, for example, if the board arrangement is: and it is X's move, the prompt should be: What is your move (possible moves at the moment are: 2, 3, 7, 9) | enter 0 to exit the game)? If the user enters anything other than 0/ valid move number (0 should terminate the game) your program should repeat the prompt above. Once the user enters a valid move, display the updated game board on screen. When it is the computer's turn (regardless of the game mode), your program should display (it could be an 'X' or 'O' move): X's selected move: Z. Number of search tree nodes generated: A.A.A where: - Z is the move/action number (a positive integer from the {1, 2, 3, 4, 5, 6, 7, 8, 9} set) selected by computer - A.A.A is the number of search tree nodes generated (the number of MiniMax nodes computer explored before making the decision [including "root"]) to select it. Follow it with the updated game board on screen. - NOTE!!! Computer's search tree move exploration order should be in a sorted fashion (1, 2, 3, 4, 5, 6, 7, 8, 9 | assuming HERE that ALL moves are available). 2 - computer (X) versus computer (O), Example: python cs480_P01_A11111111.py 2 X 1 If the number of arguments provided is NOT three (none, one, two or more than three) or arguments are invalid (incorrect ALGO, FIRST or MODE) your program should display the following error message: ERROR: Not enough/too many/illegal input arguments. and exit. Program details: Specific program details: The Tic-Tac-Toe game board is represented by 3x3 grid with cells numbered as follows - Possible moves/actions for both players match cell numbers (if a player wants to place an 'X' in the middle of the board, the move/action is '5'), Your program should begin by displaying the following information: Last Name, First Name, Axxxxxxxx solution: Algorithm: MiniMax with alpha-beta pruning First: X Mode: human versus computer where: - Axxxxxxxx is your IIT A number, - Algorithm is the algorithm specified by a command line argument, - First is the information who makes the first move as specified by a command line argument, - Mode is the game mode as specified by a command line argument, If the game mode is human versus computer display an empty board first and prompt the user to pick the move (see below)

Your task is to implement in Python the following adversarial search algorithms (refer to lecture slides and/or your textbook for details | pseudocode provided below): MiniMax (as specified by the MINIMAX-SEARCH pseudocode below) When the game is complete, your program should display a corresponding message: X WON or O WON TIE X LOST or O LOST MiniMax with alpha-beta pruning (as specified by the ALPHA-BETA-SEARCH pseudocode below), and apply them to play the game of Tic-Tac-Toe (computer). Using

Read More

Can someone please answer the coding question below in C and leave comments explaining the code

Can someone please answer the coding question below in C++ and leave comments explaining the code throughout. There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n – 1 and exactly n – 1 edges. Each node has a value associated with it, and the root of the tree is node 0.To represent this tree, you are given an integer array nums and a 2D array edges. Each nums[i] represents the ith node’s value, and each edges[j] = [uj, vj] represents

Read More

Please help in PythonPART B: Network/Traffic Flow Part B1: Background Concepts for Network/Traffic Flow Network analysis plays an important role in many industries such as engineering, information theory, and the study of transportation systems. The following analysis of traffic flow through a road network illustrates how systems of linear equations with many solutions can arise in practice. Consider the typical road network of Figure 1. It represents an area of a downtown city. The streets are all one-way, with arrows indicating the direction of traffic flow. The flow of raffic in and out of the network is measured in terms of vehicles per hour (vph). We can construct a mathematical model that can be used to analyze this network. Assume the following traffic law applies: All traffic entering an intersection must leave that intersection. This conservation of flow constraint (similar to Kirchoff’s Current Law) leads to a system of linear equations: Intersection A: Traffic in = π‘₯1 + π‘₯2 Traffic out = 400 + 225 Traffic A: π‘₯1 + π‘₯2 = 625 Intersection B: Traffic in = 350 + 125 Traffic out = π‘₯1 + π‘₯4 Traffic B: π‘₯1 + π‘₯4 = 475 Intersection C: Traffic in = 800 + 225 Traffic out = π‘₯2 + π‘₯3 Traffic C: π‘₯2 + π‘₯3 = 1050 Intersection D: Traffic in = π‘₯3 + π‘₯4 Traffic out = 600 + 300 Traffic D: π‘₯3 + π‘₯4 = 900 These constraints on the traffic are described by the following system of linear equations: π‘₯1 + π‘₯2 = 625 π‘₯1 π‘₯4 = 475 π‘₯2 + π‘₯3 = 1050 π‘₯3 + π‘₯4 = 900 The method of Gauss-Jordan elimination can be used to solve this system of equations. The augmented matrix and reduced row-echelon form of the above system are as follows: The row-echelon form (ref) of a matrix is obtained from the gauss elimination and has the following properties: β€’ All rows of zero are at the bottom β€’ The leading entry (the left-most nonzero entry) of every nonzero row is to the right of the leading entry of every row above. β€’ Any (m x n) matrix can be in row-echelon form. β€’ Some matrices in row-echelon form are also in upper triangular form if the matrix is a square matrix. Reduced row echelon form (rref) β€œreduces” the row echelon form by requiring the additional conditions: β€’ The leading entry in each nonzero row is 1 β€’ Each leading 1 is the only nonzero entry in its column The system of equations that corresponds to this reduced row-echelon form is Expressing each leading variable in terms of the remaining variable, we get As perhaps might be expected, the system of equations has many solutions (x4 is our free variable) and therefore, many traffic flows are possible. A driver does have a certain amount of choice at intersections.Part B2: Assignment for Network/Traffic Flow The following figure represents the traffic entering and leaving a β€œroundabout” road junction. Construct a mathematical model that describes the flow of traffic along the various branches using the values of Flow 1, Flow 2, Flow 3, Flow 4 as input variables.Part B2.1: Write a program that accepts for the four different flow numbers as input values. (Flow 1, Flow 2, Flow 3, Flow 4). Create an augmented matrix from the constraints on the traffic described by the system of linear equations. Part B2.2: Solve this system using the Gauss-Jordan elimination method (use a library) and output the resulting matrix.

Please help in PythonPART B: Network/Traffic Flow Part B1: Background Concepts for Network/Traffic Flow Network analysis plays an important role in many industries such as engineering, information theory, and the study of transportation systems. The following analysis of traffic flow through a road network illustrates how systems of linear equations with many solutions can arise in practice. Consider the typical road network of Figure 1. It represents an area of a downtown city. The streets are

Read More

THE UNIVERSITY OF WESTERN ONTARIO DEPARTMENT OF COMPUTER SCIENCE LONDON CANADA Software Tools and

The University of Western Ontario Department of Computer Science London, Canada Software Tools and Systems Programming (Computer Science 2211A) LAB7 The week of October 22 - October 28, 2023 This lab is an exercise with pointer arithmetic. Question 2 of the lab exercise is taken from exercise 17 in Chapter 12 of our textbook: C Programming Language: A Modern Approach (Second Edition), by K. N. King. 1. Rewrite the following function to use pointer arithmetic instead of array subscripting. (In other words, eliminate the variables i and all of the [] operators.) Note that for any array a, the expression a[i] is equivalent to *(a+i). int sum_array(const int a[], int n) { int i, sum = 0; for (i = 0; i < n; i++) sum += a[i]; return sum; }

The University of Western Ontario Department of Computer Science London, Canada Software Tools and Systems Programming (Computer Science 2211A) LAB7 The week of October 22 – October 28, 2023 This lab is an exercise with pointer arithmetic. Question 2 of the lab exercise is taken from exercise 17 in Chapter 12 of our textbook: C Programming Language: A Modern Approach (Second Edition), by K. N. King. 1. Rewrite the following function to use pointer arithmetic instead of array subscripting. (In ot

Read More

As part of the second lab assignment we have now started on expansions on our calendar program

As part of the second lab assignment, we have now started on expansions on our calendar program. Observe the changes and additions below. Your task is to code the implementation to the best of your ability. Pay close attention to all the details! Again, we will keep adding new features and updates to our program each week, on both lab assignments and online.

As part of the second lab assignment, we have now started on expansions on our calendar program. Observe the changes and additions below. Your task is to code the implementation to the best of your ability. Pay close attention to all the details! Again, we will keep adding new features and updates to our program each week, on both lab assignments and online.

Read More