Prepare a method that will guess the root of a number

Assignment Help JAVA Programming
Reference no: EM13700729

Question: Using binary search/interval halving, prepare a method that will guess the root of a number (JAVA)

We will be provided the subsequent method where int n is the number and p is the power you want the number to be raised to..

private static int power(int n, int p)

In JAVA, You need to write a method using the subsequent parameters and using the above method:

private static int root(int n, int r) {...}

I am thinking something along the lines of setting the high to n and the low to 0. 

The middle of the interval would then be n/2 = some number... 

Use this result raised to a power of r.. if is bigger than our high, which cannot be.  So the low stays at 0, and the high is now set to n/2 and so on. 

Please do proper documentation of code. I just cannot understand how to implement it.

 

 

Reference no: EM13700729

Questions Cloud

Find the average of four 16-bit unsigned integers : Write a program (starting at address $4000) to find the average of four 16-bit unsigned integers stored at locations $5000, $5002, $5004 and $5006 and store the 16-bit result at location $5010.
Outline a synthetic pathway of compounds : Question- Outline a synthetic pathway for preparing each of the following compounds, using the Grignard reaction and starting with benzene or toulene (a) 1,1-diphenylethanol; (b) 1,2-diphenylethanol; (c) 2,2-diphenylethanol; (d) 2,3-diphenyl-2-but..
Display the complete fibonacci sequence : Display the complete Fibonacci sequence until u reach a value less than or equal one million - display the count of how many numbers are in that sequence between 1 and 1000000
How many minutes are required to deposit spoon : Question- A spoon is to be electroplated with gold using 1.0 m AU(NO3)3 and 2.57 A of current. How many minutes are required to deposit 5.50 grams of gold on the spoon
Prepare a method that will guess the root of a number : Using binary search/interval halving, prepare a method that will guess the root of a number (JAVA)
Determine how long is the bar : A uniform steel bar swings from a pivot at one end with a period of 1.8s. How long is the bar
System.out.println statement : Display the value stored in num4 with the label "The result of the constant const1 multiplied by the constant const2 is " - Please use the precisely same character strings provided to you below in your System.out.println statements.
The activation energy for the ignition of the paper : Question- A paper cup is filled with water (enthalpy of vaporization for water is 40.65 kJ/mol). The activation energy for the ignition of the paper is 470 kJ. The cup holds 200.0 mL of water. Assume that the specific heat capacity of the paper is..
Estimate how far did it travel in that time : A car slows down uniformly from a speed of 20.0 m/s to rest in 4.00 s. How far did it travel in that time

Reviews

Write a Review

JAVA Programming Questions & Answers

  Method to store the product of the two arrays in third array

Write a method to store the product of the two arrays in the third array

  Create an overloaded constructor that provides values

Create a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor (the factors are + and -).

  Develop a graphical user interface based java program

Develop a Java program that can communicate with a real SMTP email server for sending emails. TNE 60003 - introduction to network programming, You program should provide a GUI and can successfully send the SMTP commands to the mail server

  Develop a reliable transfer protocol over udp

Develop a reliable transfer protocol over UDP. Focus on a Stop- and-Wait protocol.

  Calculate rental fee for different types of borrowable media

Assume that there is an abstract class called Vehicle, which has two concrete subclasses, Car and Truck. There is also an interface Loadable, which only Truck implements - calculate a rental fee for different types of borrowable media (e.g. books,..

  Calculate the largest divide by the smallest number

Please also calculate the largest divide by the smallest number provide the quotient and remainder and also put the information as a string on the applet. All the numbers will presented in two decimal places.

  Java program to implement currency converter

Write a JAVA program that helps the user convert currency. The user will enter the amount in Kuwaiti dinars. The program will print the equivalent amount in US dollar and Euros count his change.

  Design java program to enter name in input dialog box

Design the program called MailingLabel.java Program must ask user to enter name and address in input dialog box with each component of address seperated by comma.

  Write a method named validate to help a local banker

write a method named validate to help a local banker. Your method will need to utilize two input parameters and the method's return value (for its output).

  Write the code1 one argument used to justify the fact that

write the code1. one argument used to justify the fact that the stack data structure in the standard library does not

  Program 2 classes one called student one called grades

program 2 classes one called student one called grades functional requirements ask for how many students u need to

  Write java code to read integers from an input file

write java code to read integers from an input file and write only the odd numbers to an output file. the two file names will be provided on the command line as the input file followed by the output file.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd