In 2022 population of town A is less than population of town B. However, the population  of town A is growing faster than the population in town B. Write a program that  calculates and displays a year when population of town A becomes equal to larger than  that of town B.        Program specifications:  a. Write function void signature() that shows your name, student ID and  current date on the top of the output.     b. Write a function                long getPopulation(long pop, double rate)   which takes a current population and the rate of population growth as a  decimal value, and calculates population growth in a year, using                 pop += pop*decRate;    c. Assign initial population numbers for each town (in 2022) as follows: initial  population of town A is your STUDNET ID (digits only); initial population of  town B is larger by 100,000. Declare these initial values as constants. NOTE:  all variables and constants for population should be declared as  long, or long  int data type    d. Obtains floating-point rates of population growth for each town as random  floating-point number in the range 2% to 4%. (Hint: generate a random  integer in the range 20 to 40, convert to float (or double) and divide by 10.)  Do this inside a while loop to ensure that final rateA is larger than rateB  ( but these will be still percentages, like 2.6%, etc.)     e. The program then uses a loop to calculates population of each town for the  next 50 years, compares the values for each year, and display them in a table  (see example of the output). The calculations should stop when population of  A exceeds (or equal to) that of B;     f. Then it displays a message showing the year when the population of town A  will be greater than or equal to the population of town

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In 2022 population of town A is less than population of town B. However, the population 
of town A is growing faster than the population in town B. Write a program that 
calculates and displays a year when population of town A becomes equal to larger than 
that of town B. 
      Program specifications: 
a. Write function void signature() that shows your name, student ID and 
current date on the top of the output.  
 
b. Write a function  
             long getPopulation(long pop, double rate)  
which takes a current population and the rate of population growth as a 
decimal value, and calculates population growth in a year, using                
pop += pop*decRate; 
 
c. Assign initial population numbers for each town (in 2022) as follows: initial 
population of town A is your STUDNET ID (digits only); initial population of 
town B is larger by 100,000. Declare these initial values as constants. NOTE: 
all variables and constants for population should be declared as  long, or long 
int data type 
 
d. Obtains floating-point rates of population growth for each town as random 
floating-point number in the range 2% to 4%. (Hint: generate a random 
integer in the range 20 to 40, convert to float (or double) and divide by 10.) 
Do this inside a while loop to ensure that final rateA is larger than rateB 
( but these will be still percentages, like 2.6%, etc.)  
 
e. The program then uses a loop to calculates population of each town for the 
next 50 years, compares the values for each year, and display them in a table 
(see example of the output). The calculations should stop when population of 
A exceeds (or equal to) that of B;  
 
f. Then it displays a message showing the year when the population of town A 
will be greater than or equal to the population of town B.  

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY