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
A(n) ________ event is an alert that is generated when the gossip traffic enables a platform to conclude that an attack is under
Allisa [31]

Answer:

B. DDI

Explanation:

A(n) DDI event is an alert that is produce or invoke when the gossip traffic allow a platform to conclude that an attack or potential attack is under way.

A device driver is a computer program that operates or controls a particular type of device that is attached to a computer system.

A driver provides or supply a software interface to hardware devices which enable the operating systems and other computer programs to access hardware functions without needing to know the exact details in respect of the hardware being used.

DDI means Device Driver Interface

A driver relate or communicate with the device via the computer bus or communications subsystem to which the hardware is connected. Whenever a calling program invokes a routine in the driver, the driver will subsequently transmit commands to the device.

7 0
3 years ago
Excel - To clear the active cell, you can use the Ribbon, the keyboard, or the mouse.
____ [38]
The answer to your question is true
8 0
3 years ago
4) To run program short cut​
quester [9]

Answer:

Run Dialog

Open it by pressing WinKey+R. In the Run dialog, type the name of a program's .exe file and press Enter to launch it.

Explanation:

Please give me brainlist and follow

6 0
3 years ago
How does a machine learning model is deployed
yan [13]

Answer:

Explanation:

Deployment is the method by which you integrate a machine learning model into an existing production environment to make practical business decisions based on data. It is one of the last stages in the machine learning life cycle and can be one of the most cumbersome.

7 0
3 years ago
A man travel 200m towards east&lt;br /&gt;from his house then takes left&lt;br /&gt;to turn and moves 200 m north&lt;br /&gt;fin
11Alexandr11 [23.1K]
Using the Pythagorean theorem:

200^2 + 200^2 = x^2

x = 282.842712... from the original distance
4 0
3 years ago
Other questions:
  • Categories of functions specified by computer instruction?
    11·1 answer
  • "which part of an information system consists of the rules or guidelines for people to follow?"
    9·1 answer
  • Which feature is an interface between the user and the file system of a computer?
    6·2 answers
  • Windows server 2008 supports three versions of certificate templates. what version or versions of templates can be issued only f
    13·1 answer
  • Write a program that prompts the user to enter the center and a point on the circle. The program should then output the circle’s
    9·1 answer
  • What is a credit card balance? A...The amount of interest you must pay the credit card company B...The required minimum payment
    15·1 answer
  • Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked
    8·1 answer
  • How to convert a .enw file into a .pdf without downloading any applications? (If I have to, then I will. Just please tell me.)
    14·2 answers
  • Identify some advantages of using Excel over lists, paper files, or simple word documents? Describe some disadvantages of using
    15·1 answer
  • How to play Drinkopoly game?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!