1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olasank [31]
3 years ago
8

Fibonacci sequence has many applications in Computer Science. Write a program to generate Fibonacci numbers as many as desired.

After the construction, you can print the sum value of the sequence. The example is below and user input is in boldface. Enter the number of terms: 6 First 6 terms of Fibonacci numbers are: 0 1 1 2 3 5 The sum value of the above sequence is: 12 Fibonacci sequence: First few numbers are 0, 1, 1, 2, 3, 5, 8 etc., except first two terms in sequence every other term is the sum of two previous terms, For example 8 = 3 + 5 (addition of 3, 5).
Computers and Technology
1 answer:
choli [55]3 years ago
5 0
<h2>Answer:</h2>

//import Scanner class

import java.util.Scanner;

//Class header definition

public class Fibonacci_Series {

   //main method    

   public static void main(String[] args) {

       //create an object of the Scanner class to allow for user's input

       Scanner input = new Scanner(System.in);

       //Ask the user to enter the number of terms

       System.out.println("Enter the number of terms");

       //Assign user input to a variable

       int nTerms = input.nextInt();

       //Declare and initialize to zero a variable sum to hold the sum of the series.

       int sum = 0;

       //Show message

       System.out.println("First " + nTerms + " terms of Fibonacci numbers are");

       

       //Create a for loop that cycles as many times as the number of terms entered by user

       //At every term (cycle), call the fibonacci method on the term.

       //And add the number to the sum variable

       for (int i = 1; i <= nTerms; i++){

         System.out.println(fibo(i));

         sum = sum + fibo(i);

       }   //End of for loop

       //show message

       System.out.println("The sum of the above sequence is ");        

       //Display the sum of the fibonacci series

       System.out.println(sum);

   }    //End of main method

   

   //Method fibo to return the nth term of the fibonacci series

   public static int fibo(int n){

       //if n = 1,  

       // the fibonacci number is 0

       if (n <= 1){

           return 0;

       }

       //if n = 2,  

       // the fibonacci number is 1

       else if(n == 2){

           return 1;

       }

       //if n > 2, fibonacci number is the sum of the previous two numbers

       else {

           return fibo(n-1) + fibo(n-2);

       }

   }   // End of method fibo

}    // End of class declaration

<h2>Sample Output:</h2>

<em>Enter the number of terms</em>

>> 6

<em>First 6 terms of Fibonacci numbers are</em>

0

1

1

2

3

5

<em>The sum of the above sequence is  </em>

12

<h2 /><h2 /><h2>Explanation:</h2>

The above code has been written in Java.

The code contains comments explaining important parts of the code. Kindly go through the comments for better readability and understanding.

The source code file of this question has been attached to this response. Please download it and go through it for better formatting.

Download java
You might be interested in
Consider the following business environment.
ale4655 [162]

Answer:

Check the explanation

Explanation:

C-> OLAP systems allow users to analyze database information from multiple database systems at one time. The primary objective is data analysis and not data processing.

D-.Airlines use the Data Mining Techniques to improve Customer Service.

Kindly check the attached image below to see the step by step explanation to the question above.

7 0
3 years ago
Software used the control a computer's hardware
s344n2d4d5 [400]
<span>Software used the control a computer's hardware is drivers. I.e Video, Sound, Printer etc.</span>
3 0
3 years ago
Type the correct answer in the box. Spell all words correctly.
scoundrel [369]

Answer:

Patsy is possibly using a cable television system.

Explanation:

The cable television system is the private television service provision system that is provided not through signals captured by means of antennas, but through coaxial cables that are connected from the home to the poles belonging to the providers, located on the public road.

The advantages of wired televission are relatively high sound and image quality with a minimum of interference with the simplicity and low cost of subscriber receivers.

5 0
3 years ago
A cybersecurity analyst is currently investigating a server outage. The analyst has discovered the following value was entered f
drek231 [11]

Answer:D)Format string attack

Explanation:

Format string attack is the type of attack that causes to change the application functioning .This attack access the memory of the string library. It occurs while the submission of the string as input and then gets tested due to application command.

Other options are incorrect because these are the attacks that don't happens in the application for the alteration of the flow. Thus, the correct option is option(D).

8 0
3 years ago
when demonstrating 2022 versa’s maneuverability, what available systems should you point out when backing up?
lana [24]

When demonstrating 2022 Versa's maneuverability, what you should you point out while driving in a parking lot is the excellent rearward visibility that is given or shown by the RearView Monitor.

2022 Nissan Versa is a new model by Nissan. They are known to have different technology and safety features. Its includes  automatic emergency braking with pedestrian detection, remote keyless entry etc.

This vehicle comes with 2 functions such as a 5-speed manual transmission or an Xtronic Continuously Variable Transmission. With this one can quickly adjusts to the best gear ratio for a easyy acceleration and efficiency.

Learn more about 2022 Versa's from

brainly.com/question/25980600

8 0
3 years ago
Other questions:
  • What is the speedup of going from a 1-issue processor to a 2-issue processor? use your code from part a for both 1-issue and 2-i
    11·1 answer
  • She thinks it is a good idea to list the gasses bass ed on the the gas found in the atmosphere ...
    12·1 answer
  • In an IPv.4 addressing scheme the router works at layer 3 on which addressing layer?
    14·1 answer
  • The data in a database management system that identifies the names of​ tables, fields in each​ table, and the properties of each
    13·2 answers
  • Write a Twitter class that sets the Twitter user first (who is to be followed) and lets the client add up to 5 followers, which
    10·1 answer
  • Plymouth Colony was originally founded by a group of people called Pilgrims. Since Plymouth did not have an official charter fro
    15·1 answer
  • All of the following municipal securities are quoted on a yield basis EXCEPT: A) term bonds. B) secured bonds. C) tax-anticipati
    10·1 answer
  • What operation can be performed using the total feature ​
    13·1 answer
  • What is a web server?​
    11·1 answer
  • Write down a scratch program which:
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!