Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a JAVA program to solve the following problem. Your program should properly compile and run and is well documented. You need to upload into

Write a JAVA program to solve the following problem. Your program should properly compile and run and is well documented. You need to upload into Moodle the following:

 The electronic version of your SINGLE source code file after you successfully compiled and ran it. Please label your file appropriately.

Very Important Note: Do NOT upload any other files into Moodle; just ONE file with the extension “.java”.

1. Fibonacci numbers are defined by the sequence:

f1 = 1
f2 = 1
fn = fn-1 + fn-2

You need to write a Java program that prompts the user to enter the value of an integer (n) then checks if n is in the acceptable range. The acceptable range is from 1 to 50. If the user supplies a value out of the valid range, the program MUST reject it and ask the user again to enter a valid value for n. The above check needs to be implemented by a sentinel loop.

After receiving a valid value for n, the program will compute the values for all the terms of the Fibonacci series up to and including n then display these values on the screen. Output should be formatted such that each line has five values and each value is displayed left justified in a field width of 15, see the screen shot.

Computing the Fibonacci series is simple. The first two terms are predefined and after that any term is the summation of the previous two terms. Sample output is given below in case the user wants the first 50 terms.

D Please enter a valid nuster between 1501 -15 The aber entered -15 iza not valid Please enter a valid ninter 

D Please enter a valid nuster between 1501 -15 The aber entered -15 is not valid Please enter a valid unter (between: 50: 55 The super entered 55 is not valid Please enter a valid muster between - 501 50 in 89 997 ******************* ***** This program var veitten by be. TARAG ******* *** 10245 121353 1346269 14930352 16558014: 1535311003 1 13 144 1599 17711 19:410 2170309 24187817 267914296 2971215073 2 21 233 2584 28637 337011 3524570 39000169 433494437 4807526075 3 34 377 1181 16368 514229 5702007 63245996 701408739 7778742019 (End of Project) 9 55 610 6765 73025 832040 9227465 102334155 1134903170 12586260025 Page 2 of 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a Java program that solves the problem you descri... 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

Accounting Information Systems

Authors: George H. Bodnar, William S. Hopwood

11th Edition

0132871939, 978-0132871938

More Books

Students also viewed these Programming questions