LFPS - Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Punnet Square - Monohybrid Cross

Go down

Punnet Square - Monohybrid Cross Empty Punnet Square - Monohybrid Cross

Post by Sujith Fri Jun 18, 2010 5:16 am

This is a program I was working on and I just finished it yesterday. It asks the input for the Dominative and Recessive Traits and Prints the Monohybrid Cross for it. Check it out for yourself -
*Remember to save it as PunnetSquare.java and then compile it.
Code:

import java.io.*;
class PunnetSquare {
        public static void main(String[] args)throws IOException
        {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter the Dominative Trait of the Character : ");
        String domT=br.readLine();
        System.out.println();
        System.out.print("Enter the Recessive Trait of the Character : ");
        String recT=br.readLine();
        char domL=domT.charAt(0);
        char recL=Character.toLowerCase(domL);
        System.out.println("\tMonohybrid Cross");
        System.out.println("\t________________\n");
        System.out.println("\t\t"+domL+"\t"+domL);
        System.out.println("\t_______________________");
        System.out.println("\t"+recL+"|\t"+domL+""+recL+"\t"+domL+""+recL);
        System.out.println("\t"+recL+"|\t"+domL+""+recL+"\t"+domL+""+recL);
        System.out.println("\nResult:\n");
        System.out.println("100% Heterozygous "+domL+"\n\n");
        System.out.println("\t\t"+domL+"\t"+recL);
        System.out.println("\t_______________________");
        System.out.println("\t"+domL+"|\t"+domL+""+domL+"\t"+domL+""+recL);
        System.out.println("\t"+recL+"|\t"+domL+""+recL+"\t"+recL+""+recL);
        System.out.println("\nResult:\n");
        System.out.println("25% Homozygous "+domT);
        System.out.println("50% Heterozygous "+domT);
        System.out.println("50% Homozygous "+recT);
        }
}

Sujith
Sujith
LSF Expert
LSF Expert

Posts : 126

http://osalfps.org

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum