Read in two variables, year and population. Each year the population increases b
ID: 3677663 • Letter: R
Question
Read in two variables, year and population. Each year the population increases by 10%. Write a program that displays the annual population and stops in the year when the town will count over 100,000 people for the first time.
Make sure that the population is positive, non-zero.
For example:
Input Output p=87650 year=2013 Year Population------------------
2013 87650
2014 96415
2015 106056 p=-4 year=2013 Population must be larger than 0
Explanation / Answer
class Country { String name; long population; double area; Country(String name, long population, double area) { this.name = name; this.population = population; this.area = area; } double density () { if (area > 0) return population/area; else return 0; } public static void main(String[] args) { int numberOfCountries = 10; Country[] countries = new Country[numberOfCountries]; double lArea = -1; int lAreaIndex = -1; long lPop = -1; int lPopIndex = -1; double lDensity = -1; int lDensityIndex = -1; for (int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.