Punnet Square - Monohybrid Cross
LFPS - Forum :: Study Corner :: Computers :: Java :: Snippets
Page 1 of 1
Punnet Square - Monohybrid Cross
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.
*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);
}
}
LFPS - Forum :: Study Corner :: Computers :: Java :: Snippets
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Feb 14, 2012 9:02 pm by Sujith
» Kolaveri Di
Tue Nov 22, 2011 5:11 pm by Sujith
» Plane of Remembrance
Mon May 23, 2011 7:44 am by Sujith
» Board Exam Results 2011
Fri May 13, 2011 10:19 pm by Sujith
» Source Code
Wed May 04, 2011 8:06 pm by Sujith
» Rio
Wed May 04, 2011 8:04 pm by Sujith
» Fast and Furious 5
Wed May 04, 2011 7:56 pm by Sujith