Problem Statement
In genetics, most large animals have two copies of every gene, one from each parent. In the simplest genetic model, each of the genes takes on one of two forms, usually represented by an uppercase and lowercase letter of the same value ('A' and 'a', for example). The pair of genes typically contributes to the external qualities of the animal in one of two ways. If both genes are uppercase, they contribute in one way, while if both genes are lowercase, they contribute in another way. If one gene is uppercase and the other is lowercase, then the pair acts like either a pair of uppercase genes or a pair of lowercase genes depending on whether the gene represented by the uppercase letter is dominant or recessive, respectively.
In this problem, you will be given two strings, genes1 and genes2, each representing the genes from one parent. Hence, two characters from genes1 and genes2 with the same index make up a single gene. You will also be given a string dominant, telling you whether an uppercase gene is dominant or recessive, represented by 'D' and 'R', respectively (characters of dominant correspond to characters of genes1 and genes2 with the same index).
Your task
You are to return a representing the external qualities of each pair of genes. If a pair of genes has the quality of two uppercase letters, the return should have an uppercase letter, and if not the return should have a lowercase letter. In either case, each letter should have the same value as the corresponding letters of genes1 and genes2.
Constraints
-Strings genes1 and genes2 will contain only letters ('a'-'z' and
'A'-'Z').
-String dominant will contain only 'D's and 'R's.
-Strings dominant, genes1 and genes2 will each contain the same
number of characters.
-Strings dominant, genes1 and geves2 will each contain between 1
and 50 characters, inclusive.
-Corresponding letters in genes1 and genes2 will have the same
value, though potentially different cases (uppercase or
lowercase).
Example 1:
Input:
AAAA AAaa DRDR
Output:
AAAa
Example 2:
Input:
MGskgzTFQoclnDjZu mgSKGzTFQoClnDJzU DDDDDRDDDDRDDDDDD
Output:
MGSKGzTFQoclnDJZU
PLEASE USE THIS CODE in C++
#include <stdio.h>
#define MAX_LENGTH 50
int main(void) {
char genes1[MAX_LENGTH];
char genes2[MAX_LENGTH];
char dominant[MAX_LENGTH];
char output[MAX_LENGTH];
scanf("%50s", genes1); // Reads maximum 50 characters
scanf("%50s", genes2);
scanf("%50s", dominant);
// YOUR CODE GOES HERE
printf("%s", output);
return 0;
}
#include <stdio.h>
#define MAX_LENGTH 50
int main(void) {
char genes1[MAX_LENGTH];
char genes2[MAX_LENGTH];
char dominant[MAX_LENGTH];
char output[MAX_LENGTH];
scanf("%50s", genes1); // Reads maximum 50 characters
scanf("%50s", genes2);
scanf("%50s", dominant);
// YOUR CODE GOES HERE
int len = 0, i;
for(len = 0; genes1[len]!='\0'; len++); //find the length of the
string
for(i=0; i<len; i++)
{
if(dominant[i] == 'D') //if 'D' is found then check for uppercase
in both genes
{
if(genes1[i] >= 'A' && genes1[i] <= 'Z')
output[i] = genes1[i];
else
output[i] = genes2[i];
}
else //if 'R' is found then check for lowercase in both genes
{
if(genes1[i] >= 'a' && genes1[i] <= 'z')
output[i] = genes1[i];
else
output[i] = genes2[i];
}
}
output[i] = '\0';
printf("%s\n",output);
return 0;
}
Problem Statement In genetics, most large animals have two copies of every gene, one from each...
Chapter 9: Patterns of Inheritance (Genetics) Gene - Hereditary = Genetics = Character Trait = Gregor Mendel's Experiments: • Mendel used pea plants that had distinct traits • Mendel began his experiments using pea pure-bred plants - What are the two possible genotypes for pure bred plants? and Mendel was able to perform cross-fertilization between two different plants (known as a genetic cross). the resulting offspring were Purebred parents generation, Offspring of the P generation generation, Offspring of the Fi...
Problem 3. Eye colour is determined by a single gene, and each individual has two copies of the gene. For simplicity, we assume there are only blue and brown eyes. If both genes of an individual are blue, they have blue eyes; Otherwise they have brown eyes. (In technical terms, blue eyes are recessive and brown eyes are dominant.) A child inherits randomly one copy of the gene from each parent. (See e.g. season 4 of The bridge for the...
Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To compile, build, and execute an interactive program with a simple loop, conditions, user defined functions and library functions from stdio.h and ctype.h. You will write a program that will convert characters to integers and integers to characters General Requirements • In your program you will change each letter entered by the user to both uppercase AND lowercase– o Use the function toupper in #include...
Python Programming: An individual playing card is represented as a string of two characters: • the first character is from "23456789TJQKA" and represents the rank, i.e., the number or value of the card. (Note that 10 is encoded as letter T to make all card ranks to be single letters) • the second character is from "cdhs" and represents the suit (clubs, diamonds, hearts and spades respectively). For example, "Jd" would be the jack of diamonds, and "4s" would be...
A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I, ere I saw Elba A man, a plan, a canal, Panama Desserts, I stressed Kayak Write a program that determine whether an input string is a palindrome or not. Input: The program should prompt the user "Please enter a string to test for palindrome or type QUIT to exit: " and then wait for the user input....
Palindrome Detector C++ A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some well-known palindromes: Able was I, ere I saw Elba A man, a plan, a canal, Panama Desserts, I stressed Kayak Write a program that determine whether an input string is a palindrome or not. Input: The program should prompt the user "Please enter a string to test for palindrome or type QUIT to exit: " and then wait for...
C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...
Can you help me make these two methods listed below work? I have code written but it is not working. I would appreciate any advice or help. Function "isAPalidrome" accepts an array of characters and returns an integer. You must use pointer operations only, no arrays. This function should return 1 (true) if the parameter 'string' is a palindrome, or 0 (false) if 'string' is not a palindrome. A palindrome is a sequence of characters which when reversed, is the...
1. You are given a C file which contains a partially completed program. Follow the instructions contained in comments and complete the required functions. You will be rewriting four functions from HW03 (initializeStrings, printStrings, encryptStrings, decryptStrings) using only pointer operations instead of using array operations. In addition to this, you will be writing two new functions (printReversedString, isValidPassword). You should not be using any array operations in any of functions for this assignment. You may use only the strlen() function...
Learning objectives 1. To implement decisions using if statements 2. To write statements using the boolean primitive data type. 3. To compare strings and/or characters. 4. To write loops using while or for. 5. To write functions Representing playing cards and hands of cards An individual playing card is represented as a string of two characters: • the first character is from "23456789TJQKA" and represents the rank, i.e., the number or value of the card. (Note that 10 is encoded...