Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need help with this one!!! Write a program that uses a recursive call to find the integer logb of a number. Where logb returns

i need help with this one!!! image text in transcribed
image text in transcribed
image text in transcribed
Write a program that uses a recursive call to find the integer logb of a number. Where logb returns the integer log of a number in a designated base. For example, the integer base 10log of 1234 is 3 , and the integer base 2log of 1234 is 10. This is a relatively easy calculation. You simply repeatedly divide the number by the base using integer division until the quotient is less than the base and count the number of completed divisions. 1234/10=123(1)123/10=12(2)12/10=1(3)1234/2=617(1)617/2=308(2)308/2=154(3)154/2=77(4)77/2=38(5)38/2=19(6)19/2=9(7)9/2=4(8)4/2=2(9)2/2=1(10) Notice that the number 1234 is actually 1103+2102 +3101+4100 and in base 2 the number 1234 would be 1210+029 +028+127+126+025+124+023+0 22+121+020 The key point here is that the highest power value, in each of these number representations, is the integer log value. Hint use the number and the base as arguments to your recursive call, then your base case is when number is less than base and returns 0 , and the general case returns 1 plus the returned value of the recursive call. Your program should behave as follows. Please enter a number to find the integer log of 1234 Please enter the base for the calculation 2 The base 2 integer log of 1234 is 10 Would you like to enter another pair of numbers? Please enter " y " for yes or " n " for no. b Please enter " y " for yes or " n " for no. y Please enter a number to find the integer log of 1234 Please enter the base for the calculation 5 The base 5 integer log of 1234 is 4 Would you like to enter another pair of numbers? (Spring 2023) CSC 222(002N ) - Object Oriented Programming than base and returns 0 , and the general case returns 1 plu: the returned value of the recursive call. Your program should behave as follows. Please enter a number to find the integer log of 1234 Please enter the base for the calculation 2 The base 2 integer log of 1234 is 10 Would you like to enter another pair of numbers? Please enter " y " for yes or " n " for no. b Please enter " y " for yes or " n " for no. y Please enter a number to find the integer log of 1234 Please enter the base for the calculation 5 The base 5 integer log of 1234 is 4 Would you like to enter another pair of numbers? Please enter " y " for yes or " n " for no. n Good-bye! After you have solved this problem using Java, submit your Eclipse exported project zip file to this page

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions