import java.util.Scanner;

public class PunnettSquare
{
    public static void main(String[] args)
    {
		Scanner scanner = new Scanner(System.in);
		
		// parent genotype
		System.out.print("Enter the first parent's genotype: ");
		String parent1Genotype = scanner.next();
		char parent1Allele1 = parent1Genotype.charAt(0);
		char parent1Allele2 = parent1Genotype.charAt(1);
        
		System.out.print("Enter the second parent's genotype: ");
		String parent2Genotype = scanner.next();
		char parent2Allele1 = parent2Genotype.charAt(0);
		char parent2Allele2 = parent2Genotype.charAt(1);

        System.out.println("--- Punnett Square ---");
        
        // Printing the column allele headers for Parent 2
		System.out.print("     ");
		System.out.print(parent2Allele1);
		System.out.print("    ");
		System.out.println(parent2Allele2);
		
        // first top of the square
        System.out.println("  +----+----+");

        // Processing Row 1 combinations
		System.out.print(parent1Allele1);
		System.out.print(" | ");
		// combine p1a1 with p2a1
		System.out.print(parent1Allele1);
		System.out.print(parent2Allele1);
		System.out.print(" | ");
		// combine p1a1 with p2a2
		System.out.print(parent1Allele1);
		System.out.print(parent2Allele2);
		System.out.println(" |");
		
		// divider between first and second row
		System.out.println("  +----+----+");
		
		// Processing Row 1 combinations
		System.out.print(parent1Allele2);
		System.out.print(" | ");
		// combine p1a2 with p2a1
		System.out.print(parent1Allele2);
		System.out.print(parent2Allele1);
		System.out.print(" | ");
		// combine p1a2 with p2a2
		System.out.print(parent1Allele2);
		System.out.print(parent2Allele2);
		System.out.println(" |");
        
		// bottom row of the square
        System.out.println("  +----+----+");
    }
}