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]
3 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]3 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
To remove a header or footer from a document you can open the header and footer and manually delete the content true or false
romanna [79]

this is true...........................

6 0
3 years ago
Which of the following are NOT deducted on a typical pay stub
Tanya [424]
Medicare  I think Meow
6 0
3 years ago
What should you click in order to select an entire table
Aleonysh [2.5K]
I would left click on the first cell drag the mouse to highlight the table 
6 0
3 years ago
What is different between science and technology<br><br><br><br><br><br>​
scoray [572]

Answer:

Science involves observing a body of fact systematically through experiments while technology is the application of these established facts for the betterment of human lives and the world at large.

Explanation:

Science can be defined as a branch of intellectual and practical study which systematically observe a body of fact in relation to the structure and behavior of non-living and living organisms (animals, plants and humans) in the natural world through experiments.

Technology can be defined as a branch of knowledge which typically involves the process of applying, creating and managing practical or scientific knowledge to solve problems and improve human life. Technologies are applied to many fields in the world such as medicine, information technology, cybersecurity, engineering, environmental etc.

Basically, knowing how to use a technology simply means a scientist understands the appropriate method or technique to be used in the application of a technology such as when solving a problem. Also, knowing when to use a technology means to know the appropriate time to use a particular technology without it having any repercussion or adverse effect.

Generally, technology has impacted the world significantly and positively as it has helped to automate processes, increased efficiency and level of output with little or no human effort.

5 0
3 years ago
How old do you have to be to get paid to wave at liberty tax in Abilene tx
Vladimir79 [104]
<span>There are no age requirements that Liberty Tax Service has. The only restrictions are employment age laws by the government.</span>
6 0
3 years ago
Read 2 more answers
Other questions:
  • The Olympic Games that people celebrate today are much different from the Olympics that began in ancient Greece. When the Olympi
    13·2 answers
  • Tab stops are very useful when you want to A. align text into rows. B. add space between paragraphs. C. align text into columns.
    14·2 answers
  • Is “Annabelle” a true story? I mean it is fiction right?
    5·2 answers
  • EDVAC stands for? on which theory it is made on?
    15·1 answer
  • You have important data on your hard drive that is not backed up and your Windows installation is so corrupted you know that you
    11·1 answer
  • Quick!! Im taking a timed test so pls hurry!! Ill even mark as brainliets!!
    5·2 answers
  • Is a dot matrix printer an impact or non-impact printer
    12·2 answers
  • PLS HELP IM SO DESPERATE!! 40 points
    7·1 answer
  • If you feel your friend had a negative digital identity, what would you do or tell them in order to help them have a positive di
    11·2 answers
  • Does anyone have Rblx? if so write your username
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!