Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

Students also viewed these Programming questions