Question

In: Computer Science

Assume that the population of Mexico is 128 million and that the population increases 1.01 percent...

Assume that the population of Mexico is 128 million and that the population increases 1.01 percent annually. Assume that the population of the United States is 323 million and that the population is reduced 0.15 percent annually. Write an application that displays the populations for the two countries every year until the population of Mexico exceeds that of the United States, and display The population of Mexico will exceed the U.S. population in X years

The answer should look like this for Mexico:

322 321 320 319 318 312 311 310 300 299 298 297 296 295 288 287 286

This the answer for USA:

129 133 137 140 144 147 150 153 156 158 161 166 248 256 269 280

Solutions

Expert Solution

SOLUTION :

CONSIDERING THE CONDITIONS AND REQUIREMENTS FROM THE QUESTION

HERE CODE:

// Java solution for the above problem statement
import java.math.*;
import java.util.*;
class Population {
public static void main (String[] args) {
int mexico_population=128; // in million
double population_increase_rate=1.01; // in percent for Mexico

int us_population=323; // in million
double population_decrease_rate=0.15 ; // in percent for US
int n=1;

while( true )
{
int mexico=Mexico_population(mexico_population,population_increase_rate,n);
int us=US_population(us_population,population_decrease_rate,n);
if(mexico<us) {
if (n == 1) {

} else {
System.out.print(", ");
}
}
else {
System.out.println();
System.out.println("Number of years taken by Mexico to exceed US : " + n);
break;
}
n++;
System.out.print(mexico);
}
}
public static int Mexico_population(int initial_pop,double rate,int n){
int ans= (int)(initial_pop*(Math.pow((1 + (rate*0.01)),n)));
return ans;
}
public static int US_population(int initial_pop,double rate,int n){
int ans= (int)(initial_pop*(Math.pow((1 - (rate*0.01)),n)));
return ans;
}
}

NOTE : PLEASE UPVOTE ITS VERY MUCH NECESSARY FOR ME A LOT. PLZZZZ......


Related Solutions

Assume that the population of Mexico is 128 million and that the population increases 1.01 percent...
Assume that the population of Mexico is 128 million and that the population increases 1.01 percent annually. Assume that the population of the United States is 323 million and that the population is reduced 0.15 percent annually. Write an application that displays the populations for the two countries every year until the population of Mexico exceeds that of the United States, and display The population of Mexico will exceed the U.S. population in X years public class Population { public...
1)Suppose that inflation in the US is 2 percent and 10 percent in Mexico. Suppose Mexico...
1)Suppose that inflation in the US is 2 percent and 10 percent in Mexico. Suppose Mexico is expected to experience a 5% real depreciation against the US. What is the expected rate of nominal appreciation or depreciation of the peso relative to the dollar? 2) Consider a world with two countries, the United States and Europe.Prices are perfectly flexible and APPP holds at all times. The money supply at this moment in the United States is $1,000,000, real output in...
Assume that you have $100 million dollars to invest in Mexico. Explain where and how you...
Assume that you have $100 million dollars to invest in Mexico. Explain where and how you would invest this capital. What industry would you choose to invest in? How would you structure the investment (new venture, purchase an existing business, joint venture, etc.) Assume that you are presenting to prospective shareholders in your investment company. What factors will influence the expected return on your investment? Present an optimistic scenario, realistic scenario, and pessimistic scenario.
Sora Industries has 67 million outstanding shares, $128 million in debt, $55 million in cash, and...
Sora Industries has 67 million outstanding shares, $128 million in debt, $55 million in cash, and the following projected free cash flow for the next four years: Year 0 1 2 3 4 Earnings and FCF Forecast ($ million) 1 Sales 433.0 468.0 516.0 547.0 574.3 2 Growth vs. Prior Year 8.1% 10.3% 6.0% 5.0% 3 Cost of Goods Sold (313.6) (345.7) (366.5) (384.8) 4 Gross Profit 154.4 170.3 180.5 189.5 5 Selling, General, & Admin. (93.6) (103.2) (109.4) (114.9)...
In 2016, 59.7 percent of the adult population (253 million) was employed. If the employment rate increased to 62 percent,
In 2016, 59.7 percent of the adult population (253 million) was employed. If the employment rate increased to 62 percent,Instructions: In part a, round your response to one decimal place. In part b, enter your response as a whole number.a. How many more people would be working?______ millionb. By how much would output increase if per worker GDP were $122,000?$ _____ billion
Ozone Population 126 0.6 135 3.9 124 0.2 128 0.5 130 2.3 128 0.7 126 1.1...
Ozone Population 126 0.6 135 3.9 124 0.2 128 0.5 130 2.3 128 0.7 126 1.1 We wish to study the effect that the size of various U.S. cities have over ozone concentrations. The size of the populations correspond to the last census (in millions of inhabitants), and the average quantity of ozone per hour was determined in (parts per thousand millions); a) Identify the variables X and Y and analyze if the variables are linearly related. b) Determine the...
Assume that $1.4 million is deposited into a bank with a reserve requirement of 15 percent....
Assume that $1.4 million is deposited into a bank with a reserve requirement of 15 percent. Instructions: Round your answer to two decimal places. a. What is the money supply as a result?      b. If the government decides to raise the reserve requirement to 20 percent, what is the value of the money supply in this case?    
A population has a mean of 128 and a standard deviation of 32. Suppose a sample...
A population has a mean of 128 and a standard deviation of 32. Suppose a sample of size 64 is selected and x is used to estimate μ. (Round your answers to four decimal places.) (a) What is the probability that the sample mean will be within ±5 of the population mean?
A population has a mean of 128 and a standard deviation of 32. Suppose a sample...
A population has a mean of 128 and a standard deviation of 32. Suppose a sample of size 64 is selected and x is used to estimate μ. (Round your answers to four decimal places.) (a) What is the probability that the sample mean will be within ±5 of the population mean? (b) What is the probability that the sample mean will be within ±10 of the population mean?
A population has a mean of 128 and a standard deviation of 32. Suppose a sample...
A population has a mean of 128 and a standard deviation of 32. Suppose a sample of size 64 is selected and x is used to estimate μ. (Round your answers to four decimal places.) (a) What is the probability that the sample mean will be within ±5 of the population mean? (b) What is the probability that the sample mean will be within ±10 of the population mean? You may need to use the appropriate appendix table or technology...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT