![moneyyfletcher](/avatars/1109.jpg)
moneyyfletcher
21.02.2020 •
Computers and Technology
Write a program that takes both the initial size of a green crud population (in pounds) and some number of days as input, and computers from that information the size of the population (in pounds) after the specified number of days. If the input for crud population or days is a negative number, print an error message and exit.
Solved
Show answers
More tips
- S Sport How to Do Push-ups Correctly?...
- S Style and Beauty How to Grow Hair Faster: Real Methods and Advice...
- F Family and Home How to Remove Fading from Clothes: Tips and Tricks...
- F Food and Cooking How to Make Polendwitsa at Home?...
- F Family and Home Parents or Environment: Who Has the Most Influence on a Child s Upbringing?...
- P Philosophy Unbelievable stories of encounters with otherworldly forces...
- L Leisure and Entertainment How to Choose the Perfect Gift for Men on February 23rd?...
- H Health and Medicine How to Treat Whooping Cough in Children?...
- H Health and Medicine Simple Ways to Lower Cholesterol in the Blood: Tips and Tricks...
- O Other How to Choose the Best Answer to Your Question on The Grand Question ?...
Answers on questions: Computers and Technology
- C Computers and Technology 5 points to consider while enjoying services during digital application...
- B Business Economists have determined that the economy goes through a cycle of growth and decline how often....
- B Biology Which number is labeling the part of the digestive system that absorbs the nutrients from digested food into the blood?...
- H History Please select the word from the list that best fits the definition official church teaching...
- B Biology Drag each label to the correct location. Identify which sphere of Earth each Image represents. biosphere atmosphere geosphere hydrosphere answer quick pls.....
- M Mathematics When 9 times a number is increased by 30, the answer is the same as when 140 is decreased by the number. Find the number...
- C Chemistry STOICHIOMETRY QUESTION Given the following equation: Al2(SO3)3 + 6 NaOH 3 Na2SO3 + 2 Al(OH)3 a) If 10.0 g of Al2(SO3)3 is reacted with 10.0 g of NaOH, determine the limiting...
- M Mathematics Which expressions are equivalent to 4b4b4, b ? Choose all answers that apply: Choose all answers that apply: (Choice A) A b+2(b+2b)b+2(b+2b)b, plus, 2, left parenthesis, b,...
- M Mathematics What are the domain and the range for the function G(x)=log(x+2)?...
- H History When colorless hydrochloric acid is added to a red solution of cobalt nitrate, the solution turns blue. Based on the information above, which of the following is true?...
Ответ:
Complete c++ code with explanation and output results is given below
Explanation:
Fibonacci numbers are defined as F0 = 1, F1 = 1, and Fi + 2 = Fi + Fi + 1 where i = 0, 1, 2, 3,... it means that each number is the sum of previous two numbers.
Fibonacci numbers has application in population growth rates such as green crud population.
Initial size of population is taken from the user and also the number of days for population growth.
If the user input negative population or days is a negative number then error message is shown and program terminates.
the growth constant is set to 10 days meaning that population will grow after every 10 days. rate is the number of times population will grow then Fibonacci numbers are initialized and a for loop is used to compute the Fibonacci numbers that will determine the crud population growth.
Code:
#include <iostream>
using namespace std;
int main()
{
int temp = 10;
int days;
int rate;
float initial_size;
cout << "Please enter the initial weight (in pounds) of the population: "<<endl;
cin >> initial_size;
if(initial_size < 0)
{
cout<<"Error! Invalid input"<<endl;
exit(0);
}
cout << "Enter the number of days "<<endl;
cin >> days;
if(days < 0)
{
cout<<"Error! Invalid input"<<endl;
exit(0);
}
double f0 = 0;
double f1=initial_size;
double f2=f0+f1;
for(int i = 0 ; i < rate ; i++)
{
// Fibonacci sequence
f2= f1 + f0;
f0 = f1;
f1 = f2;
}
cout <<"Green Crud Population has grown to: "<< f2 << " pounds.";
return 0;
}
Output:
Please enter the initial weight (in pounds) of the population:
100
Enter the number of days
50
Green Crud Population has grown to: 800 pounds.
Please enter the initial weight (in pounds) of the population:
-50
Error! Invalid input
Ответ:
answer:
lemme get this clear.. uhh uhh
cuz i had no