Question
Define a class Country that stores the name of the country, its population, and its area. Using that class, writea program that reads in a
Define a class Country that stores the name of the country, its population, and its area. Using that class, writea program that reads in a set of countries and prints:
- the country with the largest area
- the country with the largest population
the country with the largest population density (people per square kilometer)
Implement a loop in which the user is prompted to enter country information. Continue until either the user requests to quit or enters the area (or population) that is not a number or that is non-positive (in that case print out the message Incorrect input. Exit!). Then print out the names of the country with the largest population, area and density obtained up to this point. It can happen that there are more than one country with the largest area (or population, or density). For simplicity, print out the one that appears first in the list (see the input-output sample). If the input fails during the first iteration of the loop, then do not print anything besides the message Incorrect input. Exit!.
Step 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