Write a recursive method nmbdigits

Assignment Help Programming Languages
Reference no: EM13188182

Question 1

Write a recursive method nmbDigits which takes an integer value as parameter and returns the number of digits of the parameter value (for examplenmbDigits(2054) is 4). Write a driver programTestDigits.javato test the method. Ask the user to enter an integer value then invoke the method passing the entered value as method parameter. If an illegal value is entered a message should be shown and the user will be required to enter a correct value.

Hint: Divide the number by 10 and count for how many times you can do that.

Question 2

Consider a method which calculates and returns the arithmetic mean of an array of integer values.

a) Design and implement meanIter, the iterative version of the method.

b) Design and implement meanRec, the recursive version of the method.

c) Write a driver programTestMeanVal.javato test the two methods. Consider an array of size 20 populated with random integer values in the range 1 .. 99. Invoke the two methods and display the result.

meanRec(n) =(a[n-1] + a[n-2] + ... + a[0]) / n

You should organize the right side of the above assignment statement to highlight there the expression ofmeanRec(n-1)which is: (a[n-2] + a[n-3] + ... + a[0]) / (n-1).

Reference no: EM13188182

Questions Cloud

Describe the industrial revolution : 1. began in France with the development of the steam engine and then spread to the UK and the United States. 2. began in 1550 when the English learned how to use coal to replace wood as a heat source and spread to france and eventually the United S..
How long would it take to fill the available storage space : How many cells can be in a computer's main memory if each cell's address can be represented by two hexadecimal digits? What if four hexadecimal digits are used? Explain your answer.
Determine the limit of the sequence or show that sequence : determine the limit of the sequence or show that the sequence diverges by using the appropriate Limit Laws or theorems.
When the worlds population is about to collapse : Almost all of the fossil fuels that we are now currently using were formed during the Carboniferous period.  (b) There seems to be a strong correlation between increases in the availability of food energy per person and increases in human populati..
Write a recursive method nmbdigits : Design and implement meanIter, the iterative version of the method - Write a recursive method nmbDigits which takes an integer value as parameter and returns the number of digits of the parameter value
How much water does it hold one hour later : Water is pumped out of a holding tank at a rate of 6- 6e-0.10t liters/minute, where t is in minutes since the pump is started. If the holding tank contains 1000 liters of water when the pump is started, how much water does it hold one hour later?
Explain a substitutional solid solution with silicon : Germanium forms a substitutional solid solution with silicon. Compute the weight percent of germanium that must be added to silicon to yield an alloy that contains 4.43 × 1021 Ge atoms per cubic centimeter
How much does fred make : Paul makes $25.00 a week less than the sum of what Fred and Carl together make. Carl's weekly income would be triple Steven's if he made $50.00 more a week. Paul makes $285.00 a week and Steven makes $75.00 a week. How much does Fred makE?
Explain the widespread use of slavery : The industrialization period of the late 1800's saw several new forms of energy developed, including 1. more effective use of humans and animals to power machinery using treadmills.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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