Question: Write a Java program called Numbers that reads a file containing a list of numbers and outputs, for each number in the list, the next
Write a Java program called Numbers that reads a file containing a list of numbers and outputs, for each number in the list, the next bigger number. For example, if the list is
78, 22, 56, 99, 12, 14, 17, 15, 1, 144, 37, 23, 47, 88, 3, 19
the output should look like the following:
78: 88
22: 23
56: 78
99: 144
12: 14
14: 15
17: 19
15: 17
1: 3
144: 2147483647
37: 47
23: 37
47: 56
88: 99
3: 12
19: 22
NOTE: If there is no bigger number in the sequence, just display the value of Integer.MAX_VALUE .
The output should be shown on the screen and also saved in a file.
Add code to your program that will determine how many of the numbers in the input list are Fibonacci numbers. Note that a number is a Fibonacci number if and only if one or both or is a perfect square (an integer that is also the square of another integer). After computing how many Fibonacci numbers exist in the list, your program should output # Fibonacci = n, where n is the actual count.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
