In a population, the birth rate and death rate are calculated as follows: Birth Rate= Number of Births + Population Death Rate Number of Deaths + Population For example, in a population of 100,000 that has 8,000 births and 6,000 deaths per year, Birth Rate = 8,000 ÷ 100,000 = 0.08 Death Rate = 6,000 ÷ 100,000 = 0.06 Design a Population class that stores a current population, annual number of births, and annual number of deaths for some geographic area. The class should allow these three values to be set in two ways: by passing arguments to a three- parameter constructor when a new Population object is created or by calling the setPopulation, setBirths, and setDeaths class member functions. The class should also have getBirth Rate and getDeathRate functions that compute and return the birth and death rates. Your program should properly use pointer data types where appropriate. Write a program that uses the Population class and illustrates its capabilities. Input Validation: If a population figure less than 2 is passed to the class, use a default value of 2. Population must be greater than zero. If a birth or death figure less than 0 is passed to the class, prompt user to type in a positive Sample Output: Enter total population: 100000 Enter annual number of births: 8000 Enter annnual number of deaths: 6000 Population Statistics 100000 0.080 0.060 Population: Birth Rate: Death Rate: Press any key to continue Enter total population: -1 Value must be greater than 0. Please re-enter: 1 Enter annual number of births: -1 Value cannot be negative. Please re-enter: 0 Enter annnual number of deaths: 1 Population Statistics Population: Birth Rate: Death Rate: Press any key to continue. 2 0.000 0.500 Points deducted will be at discretion of professor but all exams will be given the same grading consideration. Let's say 5 exams do not include any documentation/comments in the code, then same amount of points will be deducted on all 5 exams. Some tasks will carry more weight than other tasks. Read problem definition above and evaluate what programming concepts... (hint... the use of classes and objects... use of class functions, etc.)... in this case... will obviously carry more weight than adding, for example, comments/documentation to your programming code.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 5PE: Using classes, design an online address book to keep track of the names, addresses, phone numbers,...
icon
Related questions
Question

Kindly solve in C++ language

In a population, the birth rate and death rate are calculated as follows:
Birth Rate= Number of Births + Population
Death Rate= Number of Deaths + Population
For example, in a population of 100,000 that has 8,000 births and 6,000 deaths per year,
Birth Rate = 8,000 ÷ 100,000 = 0.08
Death Rate = 6,000 ÷ 100,000 = 0.06
Design a Population class that stores a current population, annual number of births, and annual number of deaths for
some geographic area. The class should allow these three values to be set in two ways: by passing arguments to a three-
parameter constructor when a new Population object is created or by calling the setPopulation, setBirths, and setDeaths
class member functions. The class should also have getBirthRate and getDeathRate functions that compute and return
the birth and death rates. Your program should properly use pointer data types where appropriate. Write a program
that uses the Population class and illustrates its capabilities.
Input Validation: If a population figure less than 2 is passed to the class, use a default value of 2. Population must be
greater than zero. If a birth or death figure less than 0 is passed to the class, prompt user to type in a positive
Sample Output:
Enter total population: 100000
Enter annual number of births: 8000
Enter annnual number of deaths: 6000
Population Statistics
Population: 100000
Birth Rate:
0.080
0.060
Death Rate:
Press any key to continue
• declaring appropriate class accessors ("get"
functions)
Enter total population: -1
Value must be greater than 0. Please re-enter: 1
Enter annual number of births: -1
• using appropriate class function prototypes
● initializing appropriate variables
Value cannot be negative. Please re-enter: 0
Enter annnual number of deaths: 1
Population Statistics
Points deducted will be at discretion of professor but all exams will be given the same grading consideration. Let's say 5
exams do not include any documentation/comments in the code, then same amount of points will be deducted on all 5
exams. Some tasks will carry more weight than other tasks. Read problem definition above and evaluate what
programming concepts... (hint... the use of classes and objects... use of class functions, etc.)... in this case... will obviously
carry more weight than adding, for example, comments/documentation to your programming code.
You will be graded on the following programming activities:
• declaring preprocessor directives
• documentation/comments in your code
• declaring and using a class
●
declaring appropriate class member variables
• declaring appropriate class constructors
●
declaring appropriate class mutators ("set"
functions)
● passing the right arguments and setting
appropriate parameters to accept argument
variables
• proper execution of program logic
Population:
Birth Rate:
Death Rate:
Press any key to continue
2
0.000
0.500
• appropriate use of C++ syntax
• appropriate use of input and output techniques
• appropriate use of if statements
• appropriate use of looping statements
• appropriate use of formulas to compute birth/death rates
declaring/using appropriate variables/data types
●
● declaring and creating object(s)
calling class variables and using class functions through objects
• appropriate use of validation techniques
• the use of fixed, showpoint, setprecision(), setw()
●
displaying appropriate output on creen (see above)
• Also, points (up to 30 pts) will be deducted if program does not
compile. Make sure your program compiles and runs. Remember,
if you're missing just one semicolon, program may not compile.
●
Transcribed Image Text:In a population, the birth rate and death rate are calculated as follows: Birth Rate= Number of Births + Population Death Rate= Number of Deaths + Population For example, in a population of 100,000 that has 8,000 births and 6,000 deaths per year, Birth Rate = 8,000 ÷ 100,000 = 0.08 Death Rate = 6,000 ÷ 100,000 = 0.06 Design a Population class that stores a current population, annual number of births, and annual number of deaths for some geographic area. The class should allow these three values to be set in two ways: by passing arguments to a three- parameter constructor when a new Population object is created or by calling the setPopulation, setBirths, and setDeaths class member functions. The class should also have getBirthRate and getDeathRate functions that compute and return the birth and death rates. Your program should properly use pointer data types where appropriate. Write a program that uses the Population class and illustrates its capabilities. Input Validation: If a population figure less than 2 is passed to the class, use a default value of 2. Population must be greater than zero. If a birth or death figure less than 0 is passed to the class, prompt user to type in a positive Sample Output: Enter total population: 100000 Enter annual number of births: 8000 Enter annnual number of deaths: 6000 Population Statistics Population: 100000 Birth Rate: 0.080 0.060 Death Rate: Press any key to continue • declaring appropriate class accessors ("get" functions) Enter total population: -1 Value must be greater than 0. Please re-enter: 1 Enter annual number of births: -1 • using appropriate class function prototypes ● initializing appropriate variables Value cannot be negative. Please re-enter: 0 Enter annnual number of deaths: 1 Population Statistics Points deducted will be at discretion of professor but all exams will be given the same grading consideration. Let's say 5 exams do not include any documentation/comments in the code, then same amount of points will be deducted on all 5 exams. Some tasks will carry more weight than other tasks. Read problem definition above and evaluate what programming concepts... (hint... the use of classes and objects... use of class functions, etc.)... in this case... will obviously carry more weight than adding, for example, comments/documentation to your programming code. You will be graded on the following programming activities: • declaring preprocessor directives • documentation/comments in your code • declaring and using a class ● declaring appropriate class member variables • declaring appropriate class constructors ● declaring appropriate class mutators ("set" functions) ● passing the right arguments and setting appropriate parameters to accept argument variables • proper execution of program logic Population: Birth Rate: Death Rate: Press any key to continue 2 0.000 0.500 • appropriate use of C++ syntax • appropriate use of input and output techniques • appropriate use of if statements • appropriate use of looping statements • appropriate use of formulas to compute birth/death rates declaring/using appropriate variables/data types ● ● declaring and creating object(s) calling class variables and using class functions through objects • appropriate use of validation techniques • the use of fixed, showpoint, setprecision(), setw() ● displaying appropriate output on creen (see above) • Also, points (up to 30 pts) will be deducted if program does not compile. Make sure your program compiles and runs. Remember, if you're missing just one semicolon, program may not compile. ●
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning