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
Two students are discussing the flow of electricity. Student A says that voltage is a measure of the amount of electron flow in
aivan3 [116]

The answer is C: Both of the two students are correct.

Voltage in very simple terms is what makes electric charges move. It is that push or force that causes charges to move in an electrical conductor. Thus, student A is correct since voltage is a specific measure of potential energy that exists and is always relative between two points. On the other hand, power is the rate, per unit time, at which electrical energy travels. Electrical power (P) is the product of both voltage and current and not either one separately. It is a function of voltage and current. Thus, student B is also correct.

3 0
3 years ago
The feature present in most GUIs that helps organize multiple documents or files is _____.
hoa [83]

Answer:

Folders

Explanation:

Because when people write a text document they put it in a folder called Text Documents. Then that's where they store all there text documents. There is really no other explanation.

5 0
3 years ago
What are two benefits of defining a function?
german

Answer:

enhances the readability of a program.

8 0
1 year ago
Which Internet connection type tends to use shared bandwidth?<br> Cable<br> Dial-up<br> DSL<br> ISDN
zmey [24]

Answer:

try dial-up

Explanation:

3 0
3 years ago
Read 2 more answers
Website administrators relay on ______, which is data such as the number of users who commented on, shared, viewed, or liked web
marin [14]

Answer:

b. analytics

Explanation:

-Hits are the amount of times that a website or program has been accessed.

-Analytics refers to the analysis of data to be able to make favorable decisions.

Cookies are files that are saved in a computer that are used to track the activity of a user in a website.

-Benchmaking is a technique in which a company compares its performance with businesses in the same industry.

According to this, the answer is that website administrators relay on analytics, which is data such as the number of users who commented on, shared, viewed, or liked webpage content.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Write a function that takes an array of integers and its size as parameters and prints the two largest values in the array. In t
    5·1 answer
  • Manuel is working on a project in Visual Studio. He wants to keep this program showing on the entire desktop, but he also needs
    7·1 answer
  • Write SQL statements for the following: 1. 2. 3. Change the column Z of a table XYZ to now acceptdefault value 9999 Delete a tab
    8·1 answer
  • Fill in the blank with the letter HTML
    14·1 answer
  • In order for bitlocker to protect the system volume without the aid of an external drive, your computer must:
    12·2 answers
  • What is computer code?<br> A. Java Script<br> B. XML<br> C. HTML<br> D. Any programming language
    6·1 answer
  • Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
    12·2 answers
  • We have studied machine cycle in class. Suppose that each of the four modules of machine cycle is taking 2 seconds. If there are
    5·1 answer
  • The people, procedures, hardware, software, data, and knowledge needed to develop computer systems and machines that can simulat
    13·1 answer
  • In what way, if any, is the impact of a given risk affected by the timing of a project?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!