Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write in java and read instructions, also add explanation so i can understand and see whats being done to fully get it, thank you

please write in java and read instructions, also add explanation so i can understand and see whats being done to fully get it, thank you image text in transcribed
image text in transcribed
image text in transcribed
has to enclude loops and if else statement, also print statement has to be in a loop, thanks
Lab Description: In this lab you will learn about for loop and if, if-else statements. You will also briefly review small details about syntax for writing code in JAVA. 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 o 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 0112358 (How would you get 8?) Hint: The value of certain variables will need to be reset with every iteration. 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 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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

5. Discuss the key roles for training professionals.

Answered: 1 week ago