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
Mnenie [13.5K]
4 years ago
8

Instructions The population of town A is less than the population of town B. However, the population of town A is growing faster

than the population of town B. Write a program that prompts the user to enter: The population of town A The population of town B The growth rate of town A The growth rate of town B The program outputs: After how many years the population of town A will be greater than or equal to the population of town B The populations of both the towns at that time. (A sample input is: Population of town A
Computers and Technology
1 answer:
weeeeeb [17]4 years ago
6 0

Answer: The c++ program is given below.

#include <iostream>

using namespace std;

int main() {

float townA, townB, growthA, growthB, populationA, populationB;

    int year=0;    

cout<<"Enter present population of town A : ";

cin >> townA;  

cout<<endl<<"Enter present growth rate of town A : ";

cin >> growthA;

growthA = growthA/100;  

cout<<endl<<"Enter present population of town B : ";

cin >> townB;  

cout<<endl<<"Enter present growth rate of town B : ";

cin >> growthB;

growthB = growthB/100;  

do

{

    populationA = townA + (townA * growthA);

    populationB = townB + (townB * growthB);      

    townA = populationA;

    townB = populationB;      

    year++;      

}while(populationA < populationB);  

cout<<endl<<"After " <<year<< " years, population of town A is "<<populationA << " and population of town B is "<< population<<endl;

return 0;

}

Explanation:

All the variables for population and growth rate are declared with float datatype.

The user inputs the present population of both the towns.

The growth rate entered by the user is the percentage growth.

For example, town A has 10% growth rate as shown in the output image.

The program converts 10% into float as 10/100.

growthA = growthA/100;

growthB = growthB/100;

The above conversion is done to ease the calculations.

The year variable is declared as integer and initialized to 0.

The growth in population is computed in a do-while loop. After each growth is calculated, the year variable is incremented by 1.

The loop continues until population of town A becomes greater than or equal to population of town B as mentioned in the question.

Once the loop discontinues, the final populations of town A and town B and the years needed for this growth is displayed.

The new line is introduced using endl keyword.

The function main has return type int hence, 0 is returned at the end of the program.

You might be interested in
Which relationship is possible when two tables share the same primary key?
klasskru [66]

Answer:

Many-to-one

Explanation:

Many-to-one relationships is possible when two tables share the same primary key it is because one entity contains values that refer to another entity that has unique values. It often enforced by primary key relationships, and the relationships typically are between fact and dimension tables and between levels in a hierarchy.

6 0
3 years ago
Todays hard drives give up to or more than 1000gb of space. true or false
olya-2409 [2.1K]
Its true because most 2017 harddrives come with at least 250gb 
3 0
4 years ago
The blue section of the following Venn diagram could represent which of the following Boolean statements?
Rzqust [24]

Answer:

Last option: <em>Not </em>statement

Explanation:

Anything outside the borders of the circles are considered the <em>not</em> Boolean statement since the circles represent <em>or</em> and the overlap represents <em>and</em>.

Hope this helps :)

3 0
3 years ago
Select the correct answer.
Snezhnost [94]

Answer: Adjustment layer

Explanation:

The image editing tool or technique that should be used by Carter use is an adjustment layer.

The adjustment layer that can be seen in Photoshop refers to an editing tool that's non-destructive image which can be used in adding color and tonal adjustments to a particular image without the pixels changing permanently.

By using the adjustment layers, one can be able to edit and then discard the adjustments. One can also be bake to restore the original image anytime that the person wants.

3 0
3 years ago
What is one effect the internet has had on the library
Shkiper50 [21]

Answer:

The internet provides access to an abundance of information from home, making it easier for people to get answers much faster. This efficiency has caused libraries to receive less business and less users, therefore making their service less popular.

7 0
3 years ago
Other questions:
  • Assure that major, minor, sub1 and sub2 each contain four digit numbersIf less than four digits are entered in major OR minor OR
    5·1 answer
  • How do i add a blog to my wordpress site?
    7·1 answer
  • The number of bits used to store color information about each pixel is called ____.
    13·1 answer
  • Why are video texts an example of multimedia? A. They use audio and visual elements together. B. They use one type of medium to
    13·2 answers
  • The main benefit of shielded twisted pair cabling over unshielded twisted pair is that STP is much more durable.
    13·1 answer
  • Harry needs to make a presentation on endangered species of animals. Which presentation software elements can he use to display
    5·1 answer
  • Your data warehousing project group is debating whether to create a prototype of a data warehouse before its implementation. The
    12·1 answer
  • Explain why this product was created?
    7·1 answer
  • What does a class do?
    10·1 answer
  • Why might you use the More button in the Find and Replace dialog box?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!