Can someone me with this code for C++. I am using Code Blocks. The population of
ID: 3922721 • Letter: C
Question
Can someone me with this code for C++. I am using Code Blocks.
The population of a 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 and growth rate of each town. The program outputs after how many years the population of town A will be greater than or equal to the population of town B and the populations of both the towns at that time. (A sample input is: Population of town A = 5000, growth rate of town A = 4%, population of town B = 8000, and growth rate of town B = 2%.)
Turn in:
Analysis identifying program inputs, outputs, equations, and constants.
Design including human algorithm and pseudocode algorithm
Test data
Source code
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
unsigned long populationA,populationB;
double growthRateA,growthRateB;
int year=0;
cout<<" Enter Population of Town A:";
cin>>populationA;
cout<<" Enter Growth rate of Town A:";
cin>>growthRateA;
cout<<" Enter Population of Town B:";
cin>>populationB;
cout<<" Enter Growth rate of Town B:";
cin>>growthRateB;
while(populationA<=populationB)
{
populationA = populationA + populationA*growthRateA/100;
populationB = populationB + populationB*growthRateB/100;
cout<<" Population of Town A :"<<populationA;
cout<<" Population of Town B :"<<populationB;
year++;
}
cout<<" After "<<year<<" s years the population of town A is greater than or equal to population of town B";;
return 0;
}
Output:
Success time: 0 memory: 3472 signal:0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.