Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8869007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:23:06+00:00 2026-06-14T17:23:06+00:00

public static void main(String args []) { Scanner in = new Scanner(System.in); int number

  • 0
public static void main(String args [])
{
    Scanner in = new Scanner(System.in);

    int number = 0;

    do{
        System.out.print("Which Fibonacci Number would you like? ");
        number = in.nextInt();
    }while(number < 0 || number > 71);

    System.out.printf("Fibonacci #%d is %d\n",number, fibcalc(fib));

}

 public static double fibcalc(int number)
{
    double prevNumber1 = 0;
    double prevNumber2 = 1;
    double fib = 0;

    for(int i =0; i < number; i++){
        fib = prevNumber1;
        prevNumber1 = prevNumber2;
        prevNumber2 = fib + prevNumber2;

}
    return fib;
}

The code above is what I have.

Following is the error I keep on getting:

 error: cannot find symbol
 System.out.printf("Fibonacci #%d is %d\n",number, fibcalc(fib));
                                                              ^
 symbol:   variable fib
 location: class dlin_Fibonacci

It is saying that it cannot find
fibcalc(fib)

I want to return the value of fib from my fibcalc method, so I can print it in my main method.

Does anyone know why it is not letting me?

I attempted in using just the variable fib, but the result is the same error message.
Does this have to do with the fact that variable fib is a local variable and not a class variable? If it is, then how do make it a class variable?
I tried moving the variable fib and number above my main method. Something like…

private static int number = 0;
private static double fib = 0;

public static void main(String arg[])

However, this gave me error: illegal start of an expression for the variables.

Also, can someone tell me if I am doing the return statement right?

I did some research into that going to varies sites watching videos. It seem like I followed every step. However I still don’t under what it mean by “passing the parameter”
which is the variable inside of the () within a method. does that variable comes from other method or is it just created within the method that is written? like my example above, will the variableint number be passed from my main method to my fibcalc method simply by stating it in within the ()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:23:07+00:00Added an answer on June 14, 2026 at 5:23 pm

    fibis not in scope since it’s local to fibcalc. Change the line like this:

     System.out.printf("Fibonacci #%d is %d\n",number, fibcalc(number));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My main method: public static void main(String[] args) { Scanner input = new Scanner(System.in);
public static void main(String[] args) { int i = 0; while(i==0){ System.out.println(Possibilities: R, T,
public class Foo { public static void main(String[] args) { float f; System.out.println(f); }
public class SubstringCount { public static void main(String[] args) { Scanner scan = new
import java.util.Scanner; public class CourseSplitter { public static void main(String args[]){ Scanner keyboard =
package GC; import java.util.Scanner; public class main { public static void main(String args[]) {
public class Main { public static void main(String[] args){ Class2 class2Object = new Class2();
public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
import java.util.Scanner; public class EP55Out { public static void main(String[] args) { Scanner in
import java.util.*; public class SoSanh { public static void main(String[] args) { Scanner input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.