a) Write a method PopulationTotal that accepts 2 positive values, namely the current
population (in millions, e.g. a value of 1.5 means 1.5 million people) and the growth rate (e.g.
0.14 means 14%). The method determines and returns the total population based on the current
population and growth rate. For example, if the current population for a country is 1.165 million
people, and the annual population growth rate is 10%, then the total population is 1.2815 million
people after 1 year.
b) Write a method Over180Million that accepts a positive value representing the population (in
millions). The method determines whether the population is over 180 million people, and returns
a value of true if this is so, otherwise returns a value of false.
public static double PopulationTotal(double cur_pop, double gr_rate)
{
return (cur_pop + cur_pop * gr_rate);
}
public static bool Over180Million(double pop)
{
if (pop > 180)
return true;
else
return false;
}
Comments
Leave a comment