Assume that the population of Mexico is 121 million and that the population increases 1.05% annually (new population = current population x 1.0105). Assume that the population of the United States is 315 million and that the population is reduced 0.16% annually (new population = current population x 0.9984) . Assume that the population of Japan is 127 million and that the population increases 1.01% annually (new population = current population x 1.0101). Write an application that displays the populations for the three countries every year until both Mexican and Japanese populations pass US population. Display the number of years it took for Mexicos and Japans populations to exceed that of the United States. Use both while loop and for loop to accomplish the task. Save the two files (one for each type of loop) as Population_while.java and Population_for.java

Discussion

The three basic types of loops are the FOR loop, the WHILE loop, and the DOWHILE loop. Based on what you have learned about these loops in Java programming respond to the following:

  • What are the basic similarities and distinctions among the three types of loops?
  • In what situations would one type of loop be preferred over the others? Justify your answer.
  • There are many situations where infinite loops may occur. Discuss those situations and provide best practices for each of the loop types that help avoid writing infinite loops.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.