Question 1write a recursive method nmbdigits which takes an

Assignment Help Application Programming
Reference no: EM13380068

Question 1

Write a recursive methodnmbDigitswhich 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 implementmeanIter, the iterative version of the method.

b)Design and implementmeanRec, 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.

Hint:For the recursive method, try to deduce a recurrence relation betweenmeanRec(n)andmeanRec(n-1)starting frommeanRec(n)formula (consider an arrayaof sizen):
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).

 


Submission requirements

Your completed assignment consist of theTestDigits.java and TestMeanVal.javafiles.

Reference no: EM13380068

Questions Cloud

1- prove that any relation schema with two attributes is in : 1- prove that any relation schema with two attributes is in bcnf.nbsp2- ra b c is a relation in bcnf. a is one of the
Part-11 what is the difference between interactive : part-11. what is the difference between interactive processing and real-time processing? 2. suppose a time-sharing
Design implement and test an object-oriented java program : design implement and test an object-oriented java program for processing single-variable polynomials represented as
Part 11 how many cells can be in a computers main memory if : part 11. how many cells can be in a computers main memory if each cells address can be represented by two hexadecimal
Question 1write a recursive method nmbdigits which takes an : question 1write a recursive method nmbdigits which takes an integer value as parameter and returns the number of digits
Project specificationerp project implementation atoledo : project specificationerp project implementation atoledo pizza company is planning to implement a new erp system. tim
1online bankingwhat special consequences do you foresee : 1.online bankingwhat special consequences do you foresee from information security breaches confined to online retail
Consider a class that could be used to play a game of : consider a class that could be used to play a game of hangman. the class has the following attributesthe secret wordthe
Define a class called counter an object of this class is : define a class called counter. an object of this class is used to count things so it records a count that is a

Reviews

Write a Review

Application Programming Questions & Answers

  In this project you will create an application to run in

in this project you will create an application to run in the amazon ec2 service and you will also create a client that

  Imagine that your company has decided to expand to the web

imagine that your company has decided to expand to the web. you want to reuse some data entry code that has been

  1 here is a short program it prints out the value of a

1. here is a short program. it prints out the value of a variable x. ernie and bert disagree about what will be printed

  If the user wants to read the input from a file then the

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

  Question 1we are given the following knowledge base of

question 1we are given the following knowledge base of travel informationnbspbycaraucklandhamilton.

  Basic requirementsscreen one has three edittext views and

basic requirementsscreen one has three edittext views and one button.the edittext views allow you to enter a students

  Create a application using the mvc architecture no

create a application using the mvc architecture. no scripting elements are allowed in jsp

  Rtl sa is a company which develops bespoke solutions for

rtl sa is a company which develops bespoke solutions for the rubber industry. they produce both rubber compound which

  Design a program that models the worms behavior in the

design a program that models the worms behavior in the subsequent scenarioa worm is moving toward an apple. each time

  Problem build a class for a type called fractionnbspthis

problem build a class for a type called fraction.nbspthis class is used to show a ration of two integers.nbsp include

  Part - 1 object-oriented designwrite a program that allows

part - 1 object-oriented designwrite a program that allows an instructor to keep a grade book. each students has scores

  Soda vending machine designnbsp design a soda vending

soda vending machine designnbsp design a soda vending machine that can deliver three kinds of soda a b and c. allnbsp

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