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 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; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
