Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

The population of town Ais less than the population of town B. However, the population of town Ais 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 the number of years it will take for the population of town A to become greater than or equal to the population or town B. It also outputs the populations of both towns at that time.

Your program should utilize input validation loopsto allow the user to correct errors on input so that the program can continue processing. This program should have two input validation loops:

•one to verify that the population of town A is less than the population of town B

•one to verify that the population growth rate of town A is greater than the population growth rate of town B.

Here is the algorithm for the validation loops:

Get the initial population of town A and town B.

While the initial population of town A > initial population of town B

Get the initial population of town A and town B

Get the growth rates of town A and town B.

While the growth rate of A < growth rate of B

Get the growth rate of town A and town B

To solve the problem, consider the populations of town A and town B from the initial year to the next year:

•populationA = populationA + populationA * growthRateA

•populationB = populationB + populationB * growthRateB

Set up a loop to compare the new population values to see if populationAis greater than or equal to populationB, if not, repeat the process until it is. Set up a counter inside the loop to determine the number of years it takesfor the populations to match.

C++

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education