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
vfiekz [6]
3 years ago
8

Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number

of organisms, their average daily population increase (as a percentage, expressed as a fraction in decimal form: for example 0.052 would mean a 5.2% increase each day), and the number of days they will multiply. A loop should display the size of the population for each day.
Input Validation.Do not accept a number less than 2 for the starting size of the population. If the user fails to satisfy this print a line with this message "The starting number of organisms must be at least 2.", display the prompt again and try to read the value. Similarly, do not accept a negative number for average daily population increase, using the message "The average daily population increase must be a positive value." and retrying. Finally, do not accept a number less than 1 for the number of days they will multiply and use the message "The number of days must be at least 1."
Computers and Technology
1 answer:
sineoko [7]3 years ago
6 0

Answer:

// using c++ language

#include "stdafx.h";

#include <iostream>

#include<cmath>

using namespace std;

//start

int main()

{

 //Declaration of variables in the program

 double start_organisms;

 double daily_increase;

 int days;

 double updated_organisms;

 //The user enters the number of organisms as desired

 cout << "Enter the starting number of organisms: ";

 cin >> start_organisms;

 //Validating input data

 while (start_organisms < 2)

 {

     cout << "The starting number of organisms must be at least 2.\n";

     cout << "Enter the starting number of organisms: ";

     cin >> start_organisms;

 }

 //The user enters daily input, here's where we apply the 5.2% given in question

 cout << "Enter the daily population increase: ";

 cin>> daily_increase;

 //Validating the increase

 while (daily_increase < 0)

 {

     cout << "The average daily population increase must be a positive value.\n ";

     cout << "Enter the daily population increase: ";

     cin >> daily_increase;

 }

 //The user enters number of days

 cout << "Enter the number of days: ";

 cin >> days;

 //Validating the number of days

 while (days<1)

 {

     cout << "The number of days must be at least 1.\n";

     cout << "Enter the number of days: ";

     cin >> days;

 }

 

 //Final calculation and display of results based on formulas

 for (int i = 0; i < days; i++)

 {

     updated_organisms = start_organisms + (daily_increase*start_organisms);

     cout << "On day " << i + 1 << " the population size was " << round(updated_organisms)<<"."<<"\n";

     

     start_organisms = updated_organisms;

 }

 system("pause");

  return 0;

//end

}

Explanation:

You might be interested in
Write the definition of a function powerTo which recieves two parameters, a double and an integer. If the second parameter is po
FrozenT [24]

Answer:

Following is the definition of the required function:

def powerTo( double first, int second);

if second > 0;

double result = pow(first,second);

return result;

else

return 0;

Explanation:

The explanation for above code is as follows:

  • A function named powerTo is defined, having two arguments with data type double and integer respectively.
  • A if condition is applied that checks the second parameter.
  • If the the condition: second > 0 gets true, a value is returned which is equal to first parameter raised to the second.
  • If the condition is if bracket gets false, 0 is returned as a result.

i hope it will help you!

5 0
4 years ago
Editing data is making changes to the spreadsheet. true or false
baherus [9]
True because you are editing which in this situation means making changes to something. hope I helped.
6 0
4 years ago
Read 2 more answers
Is a program that copies itself repeatedly, for example in memory or on a network, using up resources and possibly shutting down
alexandr402 [8]
It won't exactly shut down the network but it is usually a coding error that causes the program to replicate its self
7 0
4 years ago
A contractor was hired to remodel a kitchen. Which of these statements is a biased statement by the contractor?
ella [17]
<span>A contractor was hired to remodel a kitchen. This is the  biased statement by the contractor  </span>"The kitchen looks great. Don't worry; I'll meet your expectations."
7 0
4 years ago
Type the correct answer in the box. Spell all words correctly.
xz_007 [3.2K]
Set a reminder was writing down all the list of all criminals that she would require for recording her composition of the top of the list she wrote
4 0
3 years ago
Other questions:
  • The repair order is a legal document because?
    14·2 answers
  • RDBMS stands for_________________
    12·1 answer
  • A band from the 1970s has reunited. They want to revive their careers, but they do not have the funding they once did. An intern
    15·1 answer
  • It's safe to download files from the internet if u perform regular Windows security updates, that is all u need to protect your
    10·2 answers
  • When using overloaded functions in appication code, the compiler will call which one
    10·1 answer
  • How many times will the while loop that follows be executed? var months = 5; var i = 1; while (i &lt; months) { futureValue = fu
    12·1 answer
  • Database applications are seldom intended for use by a single user.
    15·1 answer
  • What are the two types of formulas in excel
    9·1 answer
  • What is the difference between ionizing and non-ionizing radiation?
    7·2 answers
  • Which longstanding restaurant chain closed its last location in lake george, new york?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!