Question
The Fibonacci sequence is a pattern of integers starting with zero and one, where each subsequent value is equal to the sum of the prior
The Fibonacci sequence is a pattern of integers starting with zero and one, where each subsequent value is equal to the sum of the prior two values: Fn = Fn-1 + Fn-2, where F0 = 0 and F1 = 1. Create a Java program which will prompt the user with How many numbers do you want to have in the sequence? (It must be greater than 2.). Then it will prompt the user with Do you want to skip the odd numbers? 1=yes, 2=no. The program will then run according to the inputs from the user. That is, if the user enters 12 and 2, then the program will just print the first 12 numbers in the sequence. If the user enters 12 and 1, then the program will try to print the first 12 numbers but will replace the odd numbers with blanks as shown below. Sample runs:
$java Fibonacci Fibonacci Sequence: How many numbers do you want to have in the sequence? (It must be greater than 2.) 12 Do you want to skip the odd numbers? 1-yes,2-no Sample 4 6 10 34 12Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started