栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Rosalind Java|Calculating Expected Offspring

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Rosalind Java|Calculating Expected Offspring

Rosalind编程问题之计算杂交后代显性基因携带个体期望值。

Calculating Expected Offspring

Given: 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);
    }
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/839004.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号