Question: Here is my code below it's only partially right. Can someone please fix my code? Please answer if you are sure you can help I

 Here is my code below it's only partially right. Can someone

Here is my code below it's only partially right. Can someone please fix my code? Please answer if you are sure you can help I do not want to waste a question

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

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;

}

}

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 vears

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!