(https: //en.wikipedia.org/wiki/Drake_equation), the number of such civilization
ID: 3885468 • Letter: #
Question
(https: //en.wikipedia.org/wiki/Drake_equation), the number of such civilizations, N, is equal to the product of a number of terms. For this assignment, we will use the following variant of the drake equation: R: the average rate of star formation in our galaxy (new stars per year), E: the average number of planets per star, L: the fraction of planets where life actually develops, I: the fraction of planets bearing life on which intelligent, civilized life, has developed C: the fraction of civilizations that have communications detectable from space, S: the span of time (in years) over which such civilizations release detectable signals This gives a combined expression of: N = R * E * L * I * C * S In this assignment, you will write a program that asks the user for the coefficients related to the Drake equation. It must then (1) print out the equation, and (2) print out the estimated number of active, communicative extra terrestrial civilizations in the Milky Way Galaxy. Example runs of the program (bold parts typed by user): > java Program 2 Program 2 (Drake Equation) by Enter the following: R: Average Rate of Milky Way star Formation in stars/year: 10000 E: Average number of planets per star: 0.2 L: fraction of planets that develop life: 0.5 I: fraction of life bearing planets where civilizations develop: 0.1 C: fraction of civilizations that have detectable communications: 0.3 s: length of time (in years) over which civilizations release signals: 300 N = R * E * L * I * C * S = 10000.0 * 0.5 * 0.2 * 0.1 * 0.3 * 300.0 = 9000.0 detectable civilizations in the Milky Way galaxyExplanation / Answer
Hi, here is the full running code, i have added comments to help you understand, please let me know if anything is not clear.
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scanner = new Scanner(System.in);
/* taking input via scanner from std in */
System.out.println("Enter the following: ");
System.out.println("R: Average rate of milky way star formation in stars/years: ");
float r = scanner.nextFloat();
System.out.println("E: Average number of planets per star: ");
float e = scanner.nextFloat();
System.out.println("L: graction of planets that develop life: ");
float l = scanner.nextFloat();
System.out.println("I: fraction of life bearing planets where cibilizations develop: ");
float i = scanner.nextFloat();
System.out.println("C: fraction of civilizations that have detectable communications: ");
float c = scanner.nextFloat();
System.out.println("S: length of time(in years) in which civilizations release signals: ");
float s = scanner.nextFloat();
/* calculating according to drake equation*/
System.out.println("N=R * E * L * I * C * S= "+r+" * "+e+" * "+l+" * "+i+" * "+c+" * "+s+" = "+r*e*l*i*c*s+" detectable cicilizations in milky way galaxy");
}
}
Thumbs up if this was helpful otherwise let me know in comments.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.