JAVA!!!!! Activity 6.1:Imagine All the People (10 pts) Worldwide population cont
ID: 3719691 • Letter: J
Question
JAVA!!!!!
Activity 6.1:Imagine All the People (10 pts) Worldwide population continues to grow every year [1]. One model for projecting the growth is given by the equation population-7.35-e 0.0071 (Year-2016) which reports the results in billions. . The letter e in the above formula is the mathematical symbol for Euler's number, the base of the natural logarithms. To calculate this exponent in Java, you will need to use the Math.exp() method from java.lang.Math Add a block comment at the top of your program with your name and section information * @author first name last name * Section info Write a program that requests a year from a user and displays the estimated population for that year as shown in the Example Run below. Create a new Scanner variable at the top of your program, named input. Prompt the user to enter the year for which they wish to calculate the world population . You must name the source code file PopGrowth.java . Then, declare a new integer variable called year. Calculate the population for the year using the formula for population shown above. . Use the Math.exp( method from java.lang.Math to calculate the power of e (Euler's number) Example Run: The outputs of the program must look like the following for you to receive full credit. For the input shown (2020) you must get the same output. However, the output numbers must change if the inputs are different. Enter the year: 2020 Estimated worldwide population in 2020: 7.561732368586969 billion Use the default formatting and precision for the numbers do NOT add any numerical formatting statements to the code.Explanation / Answer
import java.util.Scanner;
public class Population {
/*
* author first name last name
* Section
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the year: ");
int year = sc.nextInt();
double population = 7.35*Math.exp(0.0071*(year-2016));
System.out.println("Estimated worldwide population in "+year+" : "+population+" billion");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.