#Not sure how to do this loop for my Fibonacci sequence program
10 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @wispy cloud! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
This was the previous step
/**
*
* @author vjm
*/
public abstract class Fib {
/** The Fibonacci number generator 0, 1, 1, 2, 3, 5, ...
@param n index
@return nth Fibonacci number
*/
public abstract double fib (int n);
/** The order O() of the implementation.
@param n index
@return the function of n inside the O()
*/
public abstract double O (int n);
private double c;
public void recordConstant (int n, double t) {
c = (double) n + t;
}
public double estimateTime (int n) {
return c * Math.log10(n);
}
}
this is my Fib class
This is my main class
/** Get a non-negative integer from the using using ui.
If the user enters a negative integer, like -2, say
"-2 is negative...invalid"
If the user enters a non-integer, like abc, say
"abc is not an integer"
If the user clicks cancel, return -1.
@return the non-negative integer entered by the user or -1 for cancel.
*/
static int getInteger () {
String s = ui.getInfo("Enter n");
if (s == null)
return -1;
return Integer.parseInt(s);
}
public static void doExperiments (Fib fib) {
/*
getInteger(); //ask user for int
int n = getInteger();
if (n == -1)
break;
double est_time = fib.estimateTime(n);
ui.sendMessage(est_time + "microseconds");
double t = accurateTime(fib, n);
*/
System.out.println("doExperiments " + fib);
}```
These are the two methods im supposed to be editing