Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This program calculates the population of both the US and Mexico. It stops when the Mexican population reaches half of the amount of the US Population.
- class Mexico_andUS_POP {
- public static void main(String[] args){
- Banner();
- int years=0;
- int mexico_population=130000000;
- //counter for counting hte number of years.
- int US_population=332000000;
- while(mexico_population<(US_population * 0.5)){
- mexico_population = (int) (mexico_population *1.0137);
- US_population = (int) (US_population * 1.006);
- years+=1;
- }
- System.out.println("The population of Mexico will be half of the population of the US in: "+years+ " years");
- }
- public static void Banner(){
- System.out.println("Malachi Sor CS151 Homework 3");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment