Assume that the population of Mexico is 128 million and the population of the United States is 323 million. Write a program called Population that accepts two values from a user: an assumption of an annual increase in the population of Mexico and an assumption for an annual decrease in the U.S. population. Accept both figures as percentages; in other words, a 1.5 percent decrease is entered as 0.015. Write an application that displays the populations of the two countries every year until the population of Mexico exceeds that of the United States, and display the number of years it took. An example of the program is shown below: Enter the percent annual increase for Mexico population Enter as a decimal. For example, 0.5% is entered as 0.005 Enter the value >> 0.008 Enter the percent annual decrease for U.S. population Enter as a decimal. For example, 0.5% is entered as 0.005 Enter the value >> 0.002 Mexico population U.S. Population 1 129.024 million 322.354 million 2 130.056192 million 321.709292 million ... ... ... 92 266.42742275657616 million 268.665759564153 million 93 268.5588421386288 million 268.1284280450247 million The population of Mexico will exceed the U.S. population in 93 years The population of Mexico will be 268.5588421386288 million and the population of the U.S. will be 268.1284280450247 million info> The program's output is too large to include, so it has been condensed in the example above. info> Make sure to include "The population of Mexico will exceed the U.S. population in X years", where X is the number of years, in the program's output. Task 01: Create the Population class. Task #02: Task 2; The Population program displays the correct population data for Mexico and the United States.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 1FTB
icon
Related questions
Question

 

Assume that the population of Mexico is 128 million and the population of the United States is 323 million. Write a program called Population that accepts two values from a user: an assumption of an annual increase in the population of Mexico and an assumption for an annual decrease in the U.S. population. Accept both figures as percentages; in other words, a 1.5 percent decrease is entered as 0.015. Write an application that displays the populations of the two countries every year until the population of Mexico exceeds that of the United States, and display the number of years it took.

An example of the program is shown below:

Enter the percent annual increase for Mexico population

Enter as a decimal.

For example, 0.5% is entered as 0.005 Enter the value >> 0.008

Enter the percent annual decrease for U.S. population

Enter as a decimal.

For example, 0.5% is entered as 0.005

Enter the value >> 0.002

Mexico population U.S. Population 1 129.024 million 322.354 million 2 130.056192 million 321.709292 million ... ... ... 92 266.42742275657616 million 268.665759564153 million 93 268.5588421386288 million 268.1284280450247 million The population of Mexico will exceed the U.S. population in 93 years The population of Mexico will be 268.5588421386288 million and the population of the U.S. will be 268.1284280450247 million

info> The program's output is too large to include, so it has been condensed in the example above.

info> Make sure to include "The population of Mexico will exceed the U.S. population in X years", where X is the number of years, in the program's output.

Task 01: Create the Population class.

Task #02: Task 2; The Population program displays the correct population data for Mexico and the United States.

 

Cha X
Hon X
Unit X SF Assi x ta The X
Min X
Wel X
Suc: X
Prac X
literate-sniffle-x5wx9wg5x7w4fr5r.github.dev/?folder=/workspaces/9780357673423_java-programming-10e-5d83f9a... 时
che X
Q
EXPLORER
✓ STUDENT [CODESPACES: LITERATE SNIFFLE]
J Population.class
J Population.java
J Population.java x
> OUTLINE
> TIMELINE
> JAVA PROJECTS
> Codespaces: literate sniffle ΘΟΔΟ
1 Java: Lightweight Mode
student (Codespaces: literate sniffle]
Welcome x
Q Whi x
che X
+
All
System.out.println("Enter the percent annual increase for Mexico po
System.out.println("Enter as a decimal.");
System.out.println("For example, 0.5% is entered as 0.005");
System.out.print("Enter the value >> ");
double mexicoIncrease = scanner.nextDouble();
J Population.java
1
// Write your code here
2
import java.util.Scanner;
3
4
public class Population {
5
public static void main(String[] args) {
6
Scanner scanner = new Scanner(System.in);
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
10
PROBLEMS
OUTPUT
DEBUG CONSOLE
TERMINAL
PORTS
System.out.println("Enter the percent annual decrease for U.S. popu
System.out.println("Enter as a decimal.");
System.out.println("For example, 0.5% is entered as 0.005");
System.out.print("Enter the value >> ");
double usDecrease = scanner.nextDouble();
scanner.close();
double mexicoPopulation = 128.0; // in millions
double usPopulation = 323.0; // in millions
int year = 0;
System.out.println(" Mexico population\t\tu.S. Population");
while (mexicoPopulation <= usPopulation) {
Start
New File
Open File...
Clone Git Repository...
Recent
student [Codespace literate-sniffle-x5wx9wg5x7w...
student [Codespace literate-sniffle-x5wx9wg5x7w...
student [Codespace literate-sniffle-x5wx9wg5x7w...
student [Codespace literate-sniffle-x5wx9wg5x7w...
student [Codespace literate-sniffle-x5wx9wg5x7w...
More..
Walkthroughs
Get Started with VS Code for th...
Customize your editor, learn the basics,
and start coding
Learn the Fundamentals
Get Started with Java... Updated
Show welcome page on startup
+v
Layout US
Transcribed Image Text:Cha X Hon X Unit X SF Assi x ta The X Min X Wel X Suc: X Prac X literate-sniffle-x5wx9wg5x7w4fr5r.github.dev/?folder=/workspaces/9780357673423_java-programming-10e-5d83f9a... 时 che X Q EXPLORER ✓ STUDENT [CODESPACES: LITERATE SNIFFLE] J Population.class J Population.java J Population.java x > OUTLINE > TIMELINE > JAVA PROJECTS > Codespaces: literate sniffle ΘΟΔΟ 1 Java: Lightweight Mode student (Codespaces: literate sniffle] Welcome x Q Whi x che X + All System.out.println("Enter the percent annual increase for Mexico po System.out.println("Enter as a decimal."); System.out.println("For example, 0.5% is entered as 0.005"); System.out.print("Enter the value >> "); double mexicoIncrease = scanner.nextDouble(); J Population.java 1 // Write your code here 2 import java.util.Scanner; 3 4 public class Population { 5 public static void main(String[] args) { 6 Scanner scanner = new Scanner(System.in); 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 10 PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL PORTS System.out.println("Enter the percent annual decrease for U.S. popu System.out.println("Enter as a decimal."); System.out.println("For example, 0.5% is entered as 0.005"); System.out.print("Enter the value >> "); double usDecrease = scanner.nextDouble(); scanner.close(); double mexicoPopulation = 128.0; // in millions double usPopulation = 323.0; // in millions int year = 0; System.out.println(" Mexico population\t\tu.S. Population"); while (mexicoPopulation <= usPopulation) { Start New File Open File... Clone Git Repository... Recent student [Codespace literate-sniffle-x5wx9wg5x7w... student [Codespace literate-sniffle-x5wx9wg5x7w... student [Codespace literate-sniffle-x5wx9wg5x7w... student [Codespace literate-sniffle-x5wx9wg5x7w... student [Codespace literate-sniffle-x5wx9wg5x7w... More.. Walkthroughs Get Started with VS Code for th... Customize your editor, learn the basics, and start coding Learn the Fundamentals Get Started with Java... Updated Show welcome page on startup +v Layout US
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage