Computers and Technology, 23.03.2020 17:59 lukeperry
Using MatLab: An insect population doubles every generation. Write a while loop that iterates numGeneration times. Inside the while loop, write a statement that doubles currentPopulation in each iteration of the while loop.
I have set up the following code, but it only works for the first and third assessement checks.
function currentPopulation = CalculatePopulation(numGeneration, initialPopulation)
% numGeneration: Number of times the population is doubled
% currentPopulation: Starting population value
i = 2; % Loop variable counts number of iterations
currentPopulation = initialPopulation;
% Write a while loop that iterates numGeneration times
while ( i <= numGeneration )
currentPopulation = currentPopulation * (i * 2);
i = i * 2;
end
% Write a statment that doubles currentPopulation in
% each iteration of the while loop
% Hint: Do not forget to update the loop variable
end
Assessment Checks:
1. CalculatePopulation(2, 5) returns 20
2. CalculatePopulation(10, 4) returns 4096 << This is the one that won't work
3. Calculate Population (0, 78) returns 78
Could someone tell me where I went wrong with my coding?
Answers: 3
Computers and Technology, 22.06.2019 05:10
Read the code below. what will the computer print if the input for year_variable is 1700? if year_variable == 1776: print("your answer is correct. the declaration of independence was signed in “year_variable”.") elif year_variable < 1776: compute_variable = 1776 - year_variable. print("add “compute_variable“ years to your answer for the correct answer.") elif year_variable > 1776: compute_variable = year_variable - 1776 print("subtract “compute_variable” years from your answer for the correct answer.")
Answers: 1
Computers and Technology, 22.06.2019 11:00
The isometric projection camera technique provides an illusion of perspective by using things like parallax scrolling to create the illusion of 3d in a 2d game
Answers: 3
Computers and Technology, 22.06.2019 21:00
Ulia is planning to attend the same private four-year college her parents attended. she wants to save at least $18,000 in four years to contribute to her college education. which monthly deposit amounts can julia use to achieve her goal? check all that apply.
Answers: 2
Using MatLab: An insect population doubles every generation. Write a while loop that iterates numGen...
Mathematics, 12.11.2020 01:00
Chemistry, 12.11.2020 01:00
Mathematics, 12.11.2020 01:00
Mathematics, 12.11.2020 01:00
History, 12.11.2020 01:00
Arts, 12.11.2020 01:00
Physics, 12.11.2020 01:00
Mathematics, 12.11.2020 01:00
History, 12.11.2020 01:00
History, 12.11.2020 01:00
History, 12.11.2020 01:00
Mathematics, 12.11.2020 01:00