Rosalind编程问题之计算杂交后代显性基因携带个体期望值。
Calculating Expected OffspringGiven: Six nonnegative integers, each of which does not exceed 20,000. The integers correspond to the number of couples in a population possessing each genotype pairing for a given factor. In order, the six given integers represent the number of couples having the following genotypes:
AA-AA
AA-Aa
AA-aa
Aa-Aa
Aa-aa
aa-aa
Return: The expected number of offspring displaying the dominant phenotype in the next generation, under the assumption that every couple has exactly two offspring.
简单概述下大意:题目会给出六个数字,分别对应了六种基因型交配个体的数量。假设每种基因型交配产生个体数量都是2个,需要我们计算下一代中携带显性基因的个体数量的期望值。以AA-AA为例,如果有一对AA-AA,其后代100%携带显性,则其子代携带显性基因的个体数量为2;以Aa-Aa为例,如果有n对Aa-Aa,其后代75%携带显性,则其子代携带显性基因的个体数量为0.75n2。
本题语法和题目本身都比较简单,直接上代码:
public class Calculating_Expected_Offspring {
public static void main(String[] args) {
//1.输入各基因对数量
Scanner a = new Scanner(System.in);
System.out.println("请输入AA-AA对个数:");
double aa = a.nextDouble();
Scanner b = new Scanner(System.in);
System.out.println("请输入AA-Aa对个数:");
double bb = b.nextDouble();
Scanner c = new Scanner(System.in);
System.out.println("请输入AA-aa对个数:");
double cc = c.nextDouble();
Scanner d = new Scanner(System.in);
System.out.println("请输入Aa-Aa对个数:");
double dd = d.nextDouble();
Scanner e = new Scanner(System.in);
System.out.println("请输入Aa-aa对个数:");
double ee = e.nextDouble();
Scanner f = new Scanner(System.in);
System.out.println("请输入aa-aa对个数:");
double ff = f.nextDouble();
double result = (aa + bb + cc + 0.75 * dd + 0.5 * ee) * 2;
System.out.println(result);
}
}



