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

  Build web applications using ajax technologies

Develop a better understanding of building web applications using Ajax technologies and ShopOnline allows sellers to list items for selling and buyers to bid for the items based on the English Auction strategy, which is a popular strategy used in m..

  Design program to list total points scored for classroom

Student ID, classroom number, and score on the achievement test. Design a program that lists the total points scored for each of the 30 classrooms.

  Create program in visual studio-produce summary of ammounts

Create the program in Visual Studio, C#, 3.5 .Net that will produce the summary of amounts due for Pat's Auto Repair Shop. Display splash screen first.

  Write program to compute and outputs the average gpa

Write a program that computes and outputs the average GPA for both female and male students. Format your results to two decimal places. Your program should use the functions.

  Write program which uses while loops to input two integers

Write the program which uses while loops to perform the following steps: prompt the user to input two integers: firstNum and secondNum.(firstNum must be less than secondNum.

  Create math sorting game using visual basic studio

using visual basic studio 2010, Create math sorting game. Random number between 1 and 99 will be generated and displayed to the user.

  Write program to read file consisting of students test score

Write program which reads a file consisting of students test scores in range 0-100. It muts then determine number of students having scores in each of the ranges.

  Create class for hardware store to represent invoice

Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables a part number.

  Pseudo code for recursive function to print prime numbers

Write in pseudo code the recursive function which receive 2 integers (a and b) and returns sum of all common prime dividers (1 is not prime).

  Write a program that takes one command-line argument

Write a program called runsim that takes one command-line argument. Check for the appropriate command-line argument and output a usage message if the command line is incorrect.

  Program to compute person earns in a month

Write a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day.

  Values of variables of logical section of the pseudocode

What are the values of variables a, b, and c after each line of code of each logical section of the pseudocode. Show why the logical section is running.

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