Caseyd811
05-01-2003, 10:25 PM
I'm working on a project and getting nowhere.The project is on Exceptions,Console input and Threads. it has to output the nth term in the Fibonacci secuence. An unlimited number of terms can be calculated during one running of the program. I made a class called input that extendes thread, it accepts the interger from the user from the console.
i have to write a class calcOutput containing a function that calculates and outputs the nth term, given n. It also has to extend thread.
Next comes a class called sharedData that contains an integer data member. An object in this class will be used to share the value of n between the input and calcOutput threads.
Main has to declare the shared object.
The formula for the fibonacci is
public static long fibonacci(long n)
{if (n==1||n==2)
erturn 1;
else return (fib(n-1)+fib(n-2));
If anyone can help i'd be grateful.
i have to write a class calcOutput containing a function that calculates and outputs the nth term, given n. It also has to extend thread.
Next comes a class called sharedData that contains an integer data member. An object in this class will be used to share the value of n between the input and calcOutput threads.
Main has to declare the shared object.
The formula for the fibonacci is
public static long fibonacci(long n)
{if (n==1||n==2)
erturn 1;
else return (fib(n-1)+fib(n-2));
If anyone can help i'd be grateful.