You are to write a recursion routine to generate the kth term of a modified Fibonacci...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are to write a recursion routine to generate the kth term of a "modified" Fibonacci sequence. Our modified sequence will be defined as follows: modFibonacci(0) = 3 modFibonacci(1)=5 modFibonacci(2) - 8 modFibonacci(n) = modFibonacci(n-1) + modFibonacci(n-2) + modFibonacci(n-3) For your convenience several terms of this sequence are: 3 5 8 16 29 53 98 Call your new class ModFib and create a static method in it called modFibonacci. Test your new class with the following Tester class: import java.io.*; import java.util."; public class Tester 1 public static void main(String args[]) { 1 Scanner kbReader = new Scanner(System.in); System.out.print("Generate which term number? "); int k-kbReader.nextInt(); System.out.println("Term #" +1 +" is " + ModFib.modFibonacci(k)); Typical runs should look like this: Generate which term number? 5. Term #5 is 53 Generate which term number? 6 Term #6 is 98 You are to write a recursion routine to generate the kth term of a "modified" Fibonacci sequence. Our modified sequence will be defined as follows: modFibonacci(0) = 3 modFibonacci(1)=5 modFibonacci(2) - 8 modFibonacci(n) = modFibonacci(n-1) + modFibonacci(n-2) + modFibonacci(n-3) For your convenience several terms of this sequence are: 3 5 8 16 29 53 98 Call your new class ModFib and create a static method in it called modFibonacci. Test your new class with the following Tester class: import java.io.*; import java.util."; public class Tester 1 public static void main(String args[]) { 1 Scanner kbReader = new Scanner(System.in); System.out.print("Generate which term number? "); int k-kbReader.nextInt(); System.out.println("Term #" +1 +" is " + ModFib.modFibonacci(k)); Typical runs should look like this: Generate which term number? 5. Term #5 is 53 Generate which term number? 6 Term #6 is 98
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
In Figure 7.3, we presented a program that checks a string to see if the letters in the string read the same forward and backward. The previous exercise performed a similar check using words in place...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
For this computer assignment, you are to write a C++ program to implement classes to represent a binary tree (of integers) . You are required to implement assignment5.h and assignment5.cc files. Both...
-
Case 2: First Year on the Job Joe finally received that job offer in the mail. He worked part-time for First Cirrus Bank during the spring semester and the work experience had paid off. Beginning on...
-
In its 2008 annual report the Unilever Group, which published IFRS-based financial statements, reported the following in the inventory footnote (in million euros). "During 2008, 246 million euros...
-
In 1990, Jamba Juice started in San Luis Obispo, California. The company, which sells smoothie drinks, got off to a good start, opened two more cafs in 1993, and now has hundreds of outlets all the...
-
Founded in 1966 as a trader of oil and oil products, Vitol is a company with no external shareholders. All shareholders are also employees. It is a conglomerate company of energy companies that work...
-
John Donelan, the managing partner of the Dublin office of Donelan Consulting, saw the following diagram while visiting one of his clients, who owns a small manufacturing company. Mr. Donelan...
-
Transform the E-R model of project2 into a relational model. TransactionNo Date Hired Education Employee Address NumberOfItems Email 100 MemberD Name Transaction D Member TypeName Member Classify...
-
On 1 January 20x6, Company X acquires the entire share capital of $500,000 comprising of 500,000 ordinary shares in Company Y. Retained earnings as that date amounted to $100,000. In previous years,...
-
DUNA INCORPORATED is a business conglomerate that produces a variety of beverages (alcoholic and non-alcoholic], Food products (Noodles and Canned Foods) and Personal Care Items. They had been...
-
The perimeter of a rectangle is 22.8 cm, and its area is 30.53 cm. Find its length and width. length: cm width: cm
-
A mortgage of $110,000 is to be repaid by making payments of $1106 at the end of each month. If interest is 4.64% per annum compounded semi-annually, what is the term of the mortgage? State your...
-
How much will deposits of $40 made at the end of each month amount to after 9 years if interest is 7% compounded semi-annually? The deposits will amount to $ (Round the final answer to the nearest...
-
Given the following piecewise function, evaluate f (-10). Provide your answer below: f(x) = f -5x + 7 6x-3 x
-
You hold the positions in the table below. Price Shares Beta Advanced Micro Devices $8.00 303 4.92 FedEx Corp. $165.00 127 1.52 Microsoft $12.00 121 0.95 Sara Lee Corp. $19.00 239 0.99 If you expect...
-
The length of the polar curve curve is equal to O W|A A wo w/00 16 32 3 r=1 cos4 (4), 0 0 2
-
Independent random samples of sizes n1 = 30 and n2 = 50 are taken from two normal populations having the means 1 = 78 and 2 = 75 and the variances 21 = 150 and 22 = 200. Use the results of Exercise...
-
The path of a projectile fired from level ground with a speed of v0 feet per second at an angle a with the ground is given by the parametric equations x = (v0 cos )t, y = - 16t2 + (v0 sin )t a. Show...
-
If y = x4 + 2.1, find the values of y and dy in each case. (a) x = 2 and dx = x = 1 (b) x = 2 and dx = x = 0.005
-
A business is prospering in such a way that its total (accumulated) profit after t years is 1000t2 dollars. (a) How much did the business make during the third year (between t = 2 and t = 3)? (b)...
-
A summary of the Balgreen Bowling Club's cash book is shown below. From it, and the additional information, you are to construct an income and expenditure account for the year ending 31 December...
-
Why do you think non-profit-oriented organizations prepare receipts and payments accounts when they have all this information in the cash book already?
-
The following trial balance of the Grampian Golf Club was extracted from the books as on 31 December 2016: (1) Bar purchases and sales were on a cash basis. Bar inventory at 31 December 2016 was...
Study smarter with the SolutionInn App