You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
888 B
Java
38 lines
888 B
Java
4 years ago
|
import java.util.Scanner;
|
||
|
import java.util.Arrays;
|
||
|
|
||
|
public class Fibo {
|
||
|
|
||
|
private int[] inputnumbers;
|
||
|
private int[] outputnumbers;
|
||
|
|
||
|
public static void main(String args[]) throws InterruptedException {
|
||
|
|
||
|
System.out.println("Please enter the numbers of Fibonacci numbers that the program should generate: ");
|
||
|
|
||
|
//ask for input numbers
|
||
|
Scanner input = new Scanner(System.in);
|
||
|
int[] inputnumbers = new int[2];
|
||
|
int[] outputnumbers = new int[10];
|
||
|
|
||
|
for (int i = 0; i < inputnumbers.length; i++) {
|
||
|
System.out.println("Please enter number #" + i);
|
||
|
inputnumbers[i] = input.nextInt();
|
||
|
}
|
||
|
|
||
|
//create a object Tfibo who will run in a thread
|
||
|
Tfibo a = new Tfibo(inputnumbers, outputnumbers);
|
||
|
Thread t = new Thread(a);
|
||
|
|
||
|
//start the thread
|
||
|
t.start();
|
||
|
|
||
|
//wait for thread to finish
|
||
|
t.join();
|
||
|
|
||
|
//shows the result
|
||
|
System.out.println(Arrays.toString(outputnumbers));
|
||
|
|
||
|
}
|
||
|
}
|