Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4xHNncHtoGp3CZYNJTYR1/view INAWALQUINTUS. These are the names you are required to use for your lab project. Make sure the letter casing is also the same (for

image text in transcribed
image text in transcribed
4xHNncHtoGp3CZYNJTYR1/view INAWALQUINTUS. These are the names you are required to use for your lab project. Make sure the letter casing is also the same (for example, Example.java is not the same as example.java). Java file name: Fibonacci java Main class name: Fibonacci Core Requirements: WRITE A PROGRAM IN JAVA TO DISPLAY FIBONACCI SERIES The Fibonacci Sequence is a series of numbers: 0,1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. The 2 is found by adding the two numbers before it (1+1) The 3 is found by adding the two numbers before it (1+2). And the 5 is (2+3). and so on! STEPS Please note that this is a general skeleton for steps. You might need to declare variables, print statements, and/or add more lines of code as you deem necessary, to make your code functional and readable. (Hint: you will need 2 variables with values 0 and 1) Using Scanner get input from the user, asking how many numbers they want in the series. Set up an if condition ensuring that the user doesn't enter a number greater than 20. Enter number of terms for Fibonacci series: Please enter a number less than 20 Process finished with exit code If the user input meets the condition, start a for loop to iterate through the numbers, from 0 to the number n inputted, and calculate the values for the Fibonacci series. To calculate the values, on each iteration, we are assigning the second number to the first number and assigning the sum of last two numbers to the second number Read this again! For better understanding, consider this 0 1 1 2 358 (How would you get 8?) Hint: The value of certain variables will need to be reset with every iteration e 9 O Make sure to catch the edge cases: if the user inputs a negative number, 0 or 1, what will the program do? Please note that your print statement needs to be inside the loop, since there are multiple values to be printed Make sure to print the series in one line and not in multiple lines GRADING You will be graded on the following: Accuracy of your program O Documentation Correct use of loops Readability of your code OUTPUT: Enter number of terms for Fibonacci series: Fibonacci series is : 0 1 1 2 3 5 8 Process finished with exit code 0

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

1. Does your voice project confidence? Authority?

Answered: 1 week ago