Concept explainers
Population
In a population, the birth rate is the percentage increase of the population due to births, and the death rate is the percentage decrease of the population due to deaths. Write a
- The starting size of a population (minimum 2)
- The annual birth rate
- The annual death rate
- The number of years to display (minimum 1)
The program should then display the starting population and the projected population at the end of each year. It should use a function that calculates and returns the projected new size of the population after a year. The formula is
- N is the new population size,
- P is the previous population size,
- B is the birth rate,
- and D is the death rate.
Annual birth rate and death rate are the typical number of births and deaths in a year per 1,000 people, expressed as a decimal. So, for example, if there are normally about 32 births and 26 deaths per 1,000 people in a given population, the birth rate would be .032 and the death rate would be .026.
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
Concepts of Programming Languages (11th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Programming in C
Modern Database Management (12th Edition)
Computer Science: An Overview (12th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- 4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and fertilizer from a local nursery. The nursery carries different types of vegetable fertilizers in various bag sizes. When buying a particular fertilizer, they want to know the price of the fertilizer per pound and the cost of fertilizing per square foot. The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, and the area, in square feet, that can be covered by the bag. The program should output the desired result. However, the program contains logic errors. Find and correct the logic errors so that the program works properly. // Logic errors. #include #include using namespace std; int main() { double costs double area; double bagsize; cout > bagsize; cout > cost; cout > area; cout << endl; cout << "The cost of the fertilizer per pound is: $" << bagsize / cost << endl; cout << "The cost of fertilizing per square foot is: $" << area / cost << endl; return 0; }arrow_forward(Misc. application) a. The data in the following chart was collected on a recent automobile trip: Write a C++ program that accepts a mileage and gallons value and calculates the miles pergallon (mpg) for that segment of the trip. The mpg is obtained as the difference in mileage between fill-ups divided by the number of gallons of gasoline used in the fill-up. b. Modify the program written for Exercise 9a to also compute and display the cumulative mpg after each fill-up. The cumulative mpg is calculated as the difference between the mileage at each fill-up and the mileage at the start of the trip divided by the sum of gallons used to that point in the trip.arrow_forward(Statistics) This is the formula for the standard normal deviate, z, used in statistical applications: z=(X)/ X is a single value. refers to an average value. refers to a standard deviation. Using this formula, you need to write a program that calculates and displays the value of the standard normal deviate when X=85.3,=80,and=4. a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. d. Test the formula written for Exercise 7c, using the data given in the problem.arrow_forward
- (Statics) A beam’s second moment of inertia, also known as its area moment of inertia, is used to determine its resistance to bending and deflection. For a rectangular beam (see Figure 6.6), the second moment of inertia is given by this formula: Ibh3/12 I is the second moment of inertia (m4). b is the base (m). h is the height (m). a. Using this formula, write a function called beamMoment() that accepts two double- precision numbers as parameters (one for the base and one for the height), calculates the corresponding second moment of inertia, and displays the result. b. Include the function written in Exercise 4a in a working program. Make sure your function is called from main(). Test the function by passing various data to it.arrow_forwardA function may have an unlimited number of return values.arrow_forwardProblem 2: Simple Interest The formula for computing the future value of an amount that is increasing due to accumulating simple interest is F=P(1+rxi) Where F is the future value, P is the present value, is the annual interest rate (decimal value not percent), and is the total time period in years. Write a function named simpleInterest that accepts values for the three variables P, and and assings them to the output variable futureValue Function Code to call your function > Save C Reset function [futureValue] =simpleInterest (presentValue, interest RatePercent, time Years) %Enter commands to perform the computation and assign the results 3 %to the output variable defined in the function command in line 1. 1 [futureValue] =simpleInterest (10000,5.25,5) My Solutions > MATLAB Documentation C Reset Run Functionarrow_forward
- # Exercise 11: # Modify and use your pseudocode for "Find the average score" from # Day 2 homework to create a function that takes 3 arguements # and returns their average # Get three numbers from a user and use your function to compute their averagearrow_forwardJAVA CODE PLEASE Functions With No Parameters and Return Values Practice ll by CodeChum Admin Create a program that has a global integer variable assigned to a value of 1. Then, create a new function named increment that increments the global variable. In the main function, if the current value of the global variable is divisible by 3, print “Cody!”. Otherwise, print the value of that global variable. Repeatedly call the increment function until the value of the global variable is greater than 15. Output Multiple lines containing a string or an integer 1 2 Cody! 4 5 Cody! 7 8 Cody! 10 11 Cody! 13 14 Cody! Score:arrow_forwardPython XYZ store plans to give a festival discount to its customers. The store management has decided to give discount on the following criteria: Shopping Amount Discount Offered >=500 and <1000 5% >=1000 and <2000 8% >=2000 10% An additional discount of 5% is given to customers who are the members of the store. Create a program using user defined function that accepts the shopping amount as a parameter and calculates discount and net amount payable on the basis of the following conditions:Net Payable Amount = Total Shopping Amount – Discount.arrow_forward
- Question 6 # This function checks whether a given number is even or not def isEven(number): """ what it takes? a number what it does? determines if a number is even what it returns? if even, return 1 if odd, return -1 """ # your code goes in here defisEven(number): #check if the number is divisible by 2 by checking the remainder. if number % 2==0: #If remainder is 0, then its divisble by 2 and an even number #hence return-1 return1 else: #if remainder is not 0, it'll be 1, so its NOT divisible by 2 and its an odd number #hence return -1 return-1 Test case for question 6 try: if isEven(5) == -1: score['question 6'] = 'pass' else: score['question 6'] = 'fail' except: score['question 6'] = 'fail' isEven(5)arrow_forwardC++ Visual 2019 A particular talent competition has five judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer's final score is determined by dropping the highest and lowest score received, then averaging the three remaining scores. Write a program that uses this method to calculate a contestant's score. It should include the following functions: void getJudgeData() should ask the user for a judge's score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five judges. void calcScore() should calculate and display the average of the three scores that remain after dropping the highest and lowest scores the performer received. This function should be called just once by main and should be passed the five scores. The last two functions, described below, should be called by calcScore, which uses the returned information to determine which of the…arrow_forwardComputer Sciencearrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning