Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Object Oriented Programming in Java Build a program using the requirements in the photos below. Please make sure to complete entire assignment including extra credit
Object Oriented Programming in Java
Build a program using the requirements in the photos below.
Please make sure to complete entire assignment including extra credit and comments explaining code thank you.
Through this homework assignment, you will practice - Pushing your code from Eclipse to a GitHub repository created for you by GitHu Classroom - Writing a complete Java program - Using Scanner and System.in to read input from the keyboard. - Using System. out for output - Defining and using variables in Java - Using if statements in Java - Using for loops in Java Please read through the whole document before you start working on the assignment. Background The Fibonacci Sequence is one of the most infamous sequences in mathematics. The first two numbers in the sequence are given as 0 and 1, by definition: fib(0)=0fib(1)=1 The next number in the sequence is calculated by adding the two previous numbers in the sequence together. Examples: fib(2)=fib(1)+fib(0)fib(2)=1+0fib(2)=1 fib(3)=fib(2)+fib(1)fib(3)=1+1fib(3)=2fib(4)=fib(3)+fib(2)fib(4)=2+1fib(4)=3 This process repeats forever, resulting in an infinite sequence. More Examples: fib(5)=fib(4)+fib(3)fib(5)=3+2fib(5)=5fib(6)=fib(5)+fib(4)fib(6)=5+3fib(6)=8 For further reading, see this link Prompt Your task is to create a program that does the following: - Ask the user for a positive integer number as input from the console. - Checks if the number entered is positive not a positive integer and store it in a variable n (Note: zero is not a positive number!) - If the value of n is not a positive integer, the program should print out an error message to the console saying such, and then end - If the value if n is a positive integer, the program will calculate the nth Fibonacci number using a for loop - Once calculated, the nth Fibonacci number should be printed out to the console. - Extra credit: Can you handle an input that is not an integer so that it does not crash the program (i.e. causes an exception)? Feel free to look up exception handling, which we have not covered yet, or find another way to address this issue. Your program should have console outputs labeled appropriately: Your program shouldn't just print out "13" (What does it represent? Give it an appropriate label) See sample outputs for further information. Your program should calculate the Fibonacci numbers using a loop. Do not use the golden ratio. Your program must calculate the numbers with a for loop. Do not use recursion in this assignment! Sample Output Enter a positive integer number: 4 Fibonacci number 4:3 Enter a positive integer number: 6 Fibonacci number 6:8 Enter a positive integer number: 11 Fibonacci number 11: 89 Enter a positive integer number: 3 Error: 3 is not a positive integer! Enter a positive integer number: 0 Error: 0 is not a positive integer! Possible extra credit output. Feel free to change the error message: Grading CriteriaStep 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