Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import acm.program.ConsoleProgram;
- public class Fibonacci extends ConsoleProgram {
- public void run() {
- int in1 = readInt("Enter a number: ");
- int n1 = 1;
- int n2 = 1;
- int fib = 1;
- while (in1 <= 0) {
- println("Error.");
- break;
- }
- if (in1 == 1) {
- println(in1);
- }
- else {
- for (int loop = 1; loop == in1; loop++) {
- fib = n1 + n2;
- n1 = n2;
- n2 = fib;
- }
- println(fib);
- }
- }
- }
- 1) Test testNumberElve returned:
- java.lang.AssertionError: expected:<89> but was:<1>
- 2) Test testNumberZero returned:
- java.lang.AssertionError: Error
- 3) Test testNumberThirtyone returned:
- java.lang.AssertionError: expected:<1346269> but was:<1>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement