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 6805175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:33:18+00:00 2026-05-26T19:33:18+00:00

I need to generate a program that generates the Fibonacci Sequence Here is what

  • 0

I need to generate a program that generates the Fibonacci Sequence
Here is what I have so far:

import java.util.Scanner;

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

        System.out.println("Enter n:");
        int n = in.nextInt();

        EP64 fg = new EP64();

        for (int i = 1; i <= n; i++)
            System.out.println(fg.nextNumber());
    }
}



public class EP64
{

    public static void nextNumber(int n)
    {
        int fold1 = 1;
        int fold2 = 1;
        int fnew = fold1 + fold2;        
        fold1 = fnew;
    }
}

I get an error on:

    System.out.println(fg.nextNumber());

saying:
method nextNumber in class EP64 cannot be applied to given types:
required: int
found: no arguments
reason: actual and formal argument lists differ in length

and can someone also tell me if I am doing this program right? If not, help! I looked at other similar questions but I cannot make much sense of them

Thank you all!

  • 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-05-26T19:33:18+00:00Added an answer on May 26, 2026 at 7:33 pm

    method nextNumber in class EP64 cannot be applied to given types: required: int found: no arguments reason: actual and formal argument lists differ in length

    Your

    public static void nextNumber(int n)
                                 ^^^^^^^
    

    says that any call to the method must provide an integer as argument. But here:

    System.out.println(fg.nextNumber());
                                    ^^    you need to add an integer argument
    

    you violate this by providing no argument.

    As your code reads now, I’d probably drop the int n argument.

    and can someone also tell me if I am doing this program right?

    Naah, not really…

    • fold1 and fold2 should probably be member variables (so they don’t get reset in every call to the method),
    • You’re forgetting to update fold2 (you only update fold1),
    • Also, you probably want to return an int from the nextNumber method.

    Read up on

    • Official Java Tutorial: Defining Methods
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java program that generates an HTML file. The Java program takes
I need to generate thumbnails from a set of jpg's that need to have
I have written PLSQL program that generates table having usually more than 200 columns.
I have been tasked with creating a program that will generate an amortization schedule.
I have an accounting program that generates reports and saves them in excel file.
I need to come up with a program that generates an xml file like
I have a program that generates a plain text file. The structure (layout) is
I have a program (C#) that generates a list of strings (permutations of an
I need to make a program that generates a password that is saved in
I need to generate multiple databases to SQL, so I need script/program to automatically

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.