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.
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
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 #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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6cfcbabe-0283-4f69-afa3-58c47651b2d0%2Fe3a1c99e-5eb2-4015-84e3-e27c3de6a722%2Fhh1iteu_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









