Question
Setup Log into CS50 IDE e and and set up a directory for this project. Create a new source code file named main.cpp in the
Setup Log into CS50 IDE e and and set up a directory for this project. Create a new source code file named main.cpp in the directory Requirements 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 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%) Your program must contain error traps that enforce the following: • neither town's population or growth rate can be negative • town A's population cannot be greater than or equal to town B's population Error traps should keep displaying each prompt until the user enters a valid value. Sample Output Here are three separate runs showing what your output should look like. Note the error traps being demonstrated in Sample Outputs 2 and 3. Sample Output # 1 Enter the current population of town A: 5000 Enter the current population of town B: 8800 Enter the growth rate of town A: 4 Enter the growth rate of town B: 2 After 25 year(s) the population of town A will be greater than or equal to the population of town B. After 25 population of town A is 13388 After 25 population of town Bis 13110
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started