Question

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

Assume that the population of Mexico is 128 million and that the population increases 1.01 percentannually. 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 static void main(String[] args)
{
double mexicoPop = 128;
double usPop = 323;
int year = 0;
  
// your code here

System.out.println("The population of Mexico will exceed the U.S. population in " + year + " years");
System.out.println("The population of Mexico will be " + mexicoPop + " million");
System.out.println("and the population of the U.S. will be " + usPop + " million");
}
}

Homework Answers

Answer #1
public class Population
{
    public static void main(String[] args)
    {
        double mexicoPop = 128;
        double usPop = 323;
        int year = 0;

        while (mexicoPop < usPop){
            mexicoPop = mexicoPop * 1.01;
            usPop = usPop * 0.85;
            year++;
        }

        System.out.println("The population of Mexico will exceed the U.S. population in " + year + " years");
        System.out.println("The population of Mexico will be " + mexicoPop + " million");
        System.out.println("and the population of the U.S. will be " + usPop + " million");
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
How do I make this: public class Country {     private String name;     private double area;     private...
How do I make this: public class Country {     private String name;     private double area;     private int population;     public Country(String name, double area, int population) {         this.name = name;         this.area = area;         this.population = population;     }     public double getPopulationDensity() {         return population / area;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public double getArea() {         return area;     }     public void setArea(double area) {         this.area = area;     }     public int getPopulation()...
Write a program that takes two numbers from the Java console representing, respectively, an investment and...
Write a program that takes two numbers from the Java console representing, respectively, an investment and an interest rate (you will expect the user to enter a number such as .065 for the interest rate, representing a 6.5% interest rate). Your program should calculate and output (in $ notation) the future value of the investment in 5, 10, and 20 years using the following formula: future value = investment * (1 + interest rate)year We will assume that the interest...
Create a class named Purchase. Each Purchase contains an invoice number, amount of sale, and amount...
Create a class named Purchase. Each Purchase contains an invoice number, amount of sale, and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set() method for the sale amount, calculate the sales tax as 5% of the sale amount. Also include a display method that displays a purchase’s details. Provided code: import java.util.*; public class CreatePurchase { public static void main(String[] args) { Scanner input = new Scanner(System.in); Purchase purch = new...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the 2 in 2 for $1.99. private double groupPrice; //Part of price, like the $1.99 in 2 for $1.99. private int numberBought; //Total number being purchased. public Purchase () { name = "no name"; groupCount = 0; groupPrice = 0; numberBought = 0; } public Purchase (String name, int groupCount, double groupPrice, int numberBought) { this.name = name; this.groupCount = groupCount; this.groupPrice = groupPrice; this.numberBought...
Case Study 2 Seattle General Hospital (SGH) is committed to quality care and patient safety. Since...
Case Study 2 Seattle General Hospital (SGH) is committed to quality care and patient safety. Since its founding in 1895, SGH has been at the forefront of patient safety and care quality. When founder Dr. John Nelsen arrived in Seattle more than a century ago, he quickly discovered there were no hospitals that lived up to his standards for care quality and sterile technique. And so he created one. Dr. Nelsen's legacy and leadership live on today at SGH, where...
Answer the following questions from the information below a. What are the organization's marketing goals? b....
Answer the following questions from the information below a. What are the organization's marketing goals? b. What are the symptoms of the problem? In other words, which of the organization's marketing goals mentioned in section a., above are not being met? c. What is the organization's problem? Look at the symptoms and make a judgement about what their cause may be. Do not confuse symptoms with problems. Problems cause symptoms. d. Perform a SW/OT analysis: -What are the organization's internal...
Ben and Chris combined their love of hockey with a business venture. They purchased a small...
Ben and Chris combined their love of hockey with a business venture. They purchased a small portable cart and began selling hockey memorabilia outside of the hometown hockey arena. Their first year went well, but this past year has been a real struggle. Due to poor economic conditions including a loss of jobs, ticket sales at the arena are down, which has significantly hurt their sales as well. As a recent business school graduate, you explain to Ben and Chris:...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
Mattel Responds to Ethical Challenges Business Ethics This case was written by Debbie Thorne, John Fraedrich,...
Mattel Responds to Ethical Challenges Business Ethics This case was written by Debbie Thorne, John Fraedrich, O. C. Ferrell, and Jennifer Jackson, with the editorial assistance of Jennifer Sawayda. This case was developed for classroom discussion rather than to illustrate either effective or ineffective handling of an administrative, ethical, or legal discussion by management. All sources used for this case were obtained through publicly available material. Mattel, Inc. is a world leader in the design, manufacture, and marketing of family...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT