Answered step by step
Verified Expert Solution
Question
1 Approved Answer
birth rate and death rate are calculated as follows: Number of Births + Population In a population, the Birth Rate Death Rate Number of
birth rate and death rate are calculated as follows: Number of Births + Population In a population, the Birth Rate 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: Death Rate: 0.080 0.060 Press any key to continue declaring and using a class declaring appropriate class member variables declaring appropriate class constructors declaring appropriate class mutators ("set" functions) declaring appropriate class accessors ("get" functions) Enter total population: -1 Value must be greater than 8. Please re-enter: 1 Enter annual number of births: -1 using appropriate class function prototypes initializing appropriate variables passing the right arguments and setting appropriate parameters to accept argument variables proper execution of program logic 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 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 screen (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.
Step by Step Solution
★★★★★
3.40 Rating (162 Votes )
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