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
Courts are struggling with the privacy implications of GPStracking. In 2009, New York’s highest court held that policeofficers m
aniked [119]

Answer:

warrant

Explanation:

New York State's highest court ruled in 2009 that tracking a person via the global positioning system (GPS) without a warrant violated his right to privacy.

6 0
3 years ago
Which feature of a word processing program enables you to represent any numerical data in the form of a diagram?
WARRIOR [948]
I think the answer to this is SmartArt. it helps you create any type of diagrams in either powerpoints or word. 
7 0
3 years ago
Read 2 more answers
If you would like to give another user permissions on your mailbox or to particular folders within your mailbox, which role shou
Darya [45]

Answer:

Delegate

Explanation:

8 0
2 years ago
Which element adds a page turn effect to the slides in a presentation
zepelin [54]

slide transition adds a page turn effect

6 0
3 years ago
Say you're designing your own operating system, and you want to implement your own paging system. Give one advantage of having s
zheka24 [161]

Answer and Explanation:

Advantages of having large page sizes: Smaller page table, less page faults, less overhead in reading/writing of pages.

Advantages of having small page sizes: reduces internal fragmentation, better with locality of reference.

7 0
3 years ago
Read 2 more answers
Other questions:
  • A statement describing both the requirements that must be met by a product or process amd the ways in which satisfaction of the
    8·2 answers
  • An information security ________ is a specification of a model to be followed during the design, selection, and initial and ongo
    11·2 answers
  • (Convert milliseconds to hours, minutes, and seconds) Write a function that converts milliseconds to hours, minutes, and seconds
    12·1 answer
  • The term ____ means that a public information network such as an Internet service provider (ISP) should treat all users, all pla
    9·1 answer
  • Look at the four schematic symbols shown in the figure above. Each of the symbols is labeled with a number. Which of the followi
    11·1 answer
  • How many passes will it take to find the four in this list? 4, 5, 6, 7, 8, 9, 10 1 2 3 4
    12·2 answers
  • PLZ HELP! ANSWER (WITH CORRECT ANSWER AND EXPLANATION THAT ACTUALLY IS CORRECT) GETS BRAINLIEST!
    13·1 answer
  • Xbox one is not turning on and power brick is orange why is that?​
    6·1 answer
  • Practising some questions for board exams for class 12 python,pls help with detailed answer
    14·1 answer
  • As part of your regular system maintenance, you install the latest operating system updates on your Windows 10 computer. After s
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!