Question
im in an introductory programming class (C++) and i have to create a class called country, a procedure to print this class and a most
im in an introductory programming class (C++) and i have to create a class called country, a procedure to print this class and a most dense function which inputs a vector of countries. i was given the main body and instructed not to change anything in it, all the code above it is what i have already typed out. the other stuff i need for this program is stated above. if someone could help me finish this program that would be greatly appreciated. i dont believe i have made any errors in what i have wrote but i possibly could have. im aware this is not a small problem so any help with be granted a thumbs up. it also really helps me when there are comments on the code to explain what is happening, this way i learn for the future. have a great day thanks :)
also none of the functions should cout anything unless stated.
The Country class: ountry.cpp 1. The Country class (note the capital C) three member variables, area (use a double), population (use either an int or an unsigned int) and name (use a string). All member variables should be in the private portion of the class definition. In this problem, will not make the member variable constant. (After all, the populations of countries changes over time.) 2. The class should have one constructor function which inputs three pa- rameters (the population, area, and name). The constructor should use an initializer list as shown in class. It should also use assert to ensure that both population and area are strictly positive. (Zero should cause an error. Don't forget to include cassert.) 3. It should also have three accessor functions called get_area, get name, and get_population which return the area, the name, and the population. Make sure to include const here. For these functions you do not need to use function declarations (i.e. you can write them inside the class, and don't need to write them below the main). 4. It should have three mutator functions, add pop, multiply-pop and change_name. These functions should all do what their name suggests. For example, if the population was 1,000,000 and you call c.add_pop(5) the population should change to 1,000,005, but if you call c.multiply-pop(5) it should change to 5.000.000. For these three functions, you must use function declarations. (See the Rectangle6 example from class.) For add pop, your input should be an int, for multiply-pop it should be a double, and for change name, it should be a string. The print procedure: This procedure should print a Country. In particular, it should cout something in the format shown below: Japan has population 1.234,567 and area 3,234. (Those numbers are made up.) You should decide whether to use pass by value, pass by reference, or pass by reference to a const and must make the appropriate choice in order to get full credit. Ti The most dense function: 1. This function should have one parameter named countries, which is a vector of Countrys (i.e. it is a vector, and every entry of the vector is a Country). 2. It should return the Country with the highest population density. (popu- lation divided by area). 2 3. For this function, you don't have to worry about strange or invalid input. You can assume that countries is a vector of Countrys; that there is at least one country in the vector, and that none of the areas are zero. 4. You don't have to worry about the possibility that there is a tie, i.e. that two different countries have exactly the same density. 5. You should decide whether to use pass by value, pass by reference, or pass by reference to a const and must make the appropriate choice in order to get full credit. (Global Scope) 1 2 #includeStep by Step Solution
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