Question

In: Computer Science

*******IN PSEUDOCODE AND C++******* Program 0 (Warm-up, 40 pts): Deoxyribonucleic acid, or DNA, is comprised of...

*******IN PSEUDOCODE AND C++******* Program 0 (Warm-up, 40 pts): Deoxyribonucleic acid, or DNA, is comprised of four bases: (G)uanine, (C)ytosine, (A)denine and (T)hymine. Ribonucleic acid, or RNA, is different than DNA in that it contains no Thymine; thymine is replaced with something called (U)racil. For this assignment, you will create an array of 255 characters. You must start by filling the array with random characters of G, C, A and T.   You must then print out the array. Next, replace all the instances of Thymine with Uracil. Finally, you must print out the array again. In your solution, you must write at least one function that contributes to the solution. You must use the length attribute of the array in your answer.

Sample run

CATGGCGTCTTGCCAAGGCGGTTCCTTGTCTTGATGATGGCTGCGAGTTCCGAGTCGCCTTTTCTATGAGTCGCGAAGTATGCGGTCAAATTATGCTTGTCCGCTGTACTAGGCCCACGGATCTCCTCAGACAGCGTCGATGTCGGAATTCGCGGGGAGGAATACTAAACATGCTGAAGTTGATACATGTACAATTGCCGCGAACCAGGTGCACAGGGTGCCCAACGATCCATGTGGAACGAGAGCGATCTAGCC

CAUGGCGUCUUGCCAAGGCGGUUCCUUGUCUUGAUGAUGGCUGCGAGUUCCGAGUCGCCUUUUCUAUGAGUCGCGAAGUAUGCGGUCAAAUUAUGCUUGUCCGCUGUACUAGGCCCACGGAUCUCCUCAGACAGCGUCGAUGUCGGAAUUCGCGGGGAGGAAUACUAAACAUGCUGAAGUUGAUACAUGUACAAUUGCCGCGAACCAGGUGCACAGGGUGCCCAACGAUCCAUGUGGAACGAGAGCGAUCUAGCC

Solutions

Expert Solution

C++ code for the give problem is written below. Comments have been added to make the code comprehensible.

The code does the following in sequence:

  1. Fills a array dna with random bases (characters), 'G", 'C', 'U' or 'T'.
  2. Prints the dna array.
  3. Using dna array, fills up another rna array except all Thymine bases gets replaced with Uracil.
  4. Prints the rna array.
  5. Length of array (sizeof) is used in for loops to get the length of the array for iteration.

======================================================================================

#include <iostream>

using namespace std;

//Define a function getBase() which will be used to generate a random number between 1 and 4 and use it
//for returning either 'G', 'C', 'A' or 'T' using a switch statement
char getBase()
{
    //Generate a random number between 1 and 4 using rand(), remember main() has already called srand() by the time getBase() gets called from for loop
    int randNum = (rand() % 4) + 1;
    //Use switch to map to either 'G', 'C', 'A' or 'T' base and return to the caller
    switch(randNum)
    {
        case 1:
            return 'G';
            break;
        case 2:
            return 'C';
            break;
        case 3:
            return 'A';
            break;
        case 4:
            return 'T';
            break;
    }
}

int main()
{
    //Initialize two character arrays to store our random characters
    char dna[255], rna[255];
  
    //Seed the random number generator with current time so that each run will generate a different sequnce of characters
    //Just using rand() without srand() will cause the same random pattern of character sequence to be generated everytime
    srand(time(NULL));
  
    //Run a loop 255 times to generate and store 255 random characters for dna character array using getBase() function
    for(int i=0; i<sizeof(dna); i++)
        dna[i]=getBase();
  
    //Print the DNA array  
    cout << "DNA Sequence: " << dna << endl;

    //Replace all the instances of Thymine with Uracil
    for (int i=0; i<sizeof(dna); i++)
    {
        //If base is Thymine, replace with Uracil
        if(dna[i]=='T')
            rna[i]='U';
        //Else just copy the same base as of dna in rna character array
        else
            rna[i]=dna[i];
    }
  
    //Print the RNA array  
    cout << "RNA Sequence: " << rna << endl;

    return 0;
}

======================================================================================

Sample Output:

======================================================================================

DNA Sequence: AAAGCTCAGTGTTTGTGCGTGTTATTATTTTCCCCAGTCGACTCCTGCCGGCTTTTTCAAGAGCTCTGGGGAAGTTTTGGTGCTGGATCGCCACAATAATAAAGACTACTAGGGTGGCTAAGTGAAACGGGATATCGATCAACAACAAACGGCGCTATGAGCGTTTGTAGGGAA
AGTGACCTAATTACAATATTCTTAACATCGCTGGTACGCTAGAGCCTGTAGCCTTGGCTCCGGCGTTCTCCCCTATGCTGT                                                                                                      
RNA Sequence: AAAGCUCAGUGUUUGUGCGUGUUAUUAUUUUCCCCAGUCGACUCCUGCCGGCUUUUUCAAGAGCUCUGGGGAAGUUUUGGUGCUGGAUCGCCACAAUAAUAAAGACUACUAGGGUGGCUAAGUGAAACGGGAUAUCGAUCAACAACAAACGGCGCUAUGAGCGUUUGUAGGGAA
AGUGACCUAAUUACAAUAUUCUUAACAUCGCUGGUACGCUAGAGCCUGUAGCCUUGGCUCCGGCGUUCUCCCCUAUGCUGU

======================================================================================

DNA Sequence: CCTTTGTACGAATGGTTATATTGGTTTATGGGAGGCGTTCTAGTAGACACTCGGATTCCTCATTATCATGTAATCGTTCAGCTCCCGGAATGGTTAAGGCCTGTTCGACCGCAGATCTGGCTGCATTCGTACAAGCGGGCAGAGGCGAGGACTAAACCTCGCAAGTGGTGCCGT
ACGATGACCCTTTGGAAGGGTGTTGTTCGTGAGCGTCAGTGTATGTAATAAAAACACGTCGTGGGGGATGCTGTAGAGAAA                                                                                                      
RNA Sequence: CCUUUGUACGAAUGGUUAUAUUGGUUUAUGGGAGGCGUUCUAGUAGACACUCGGAUUCCUCAUUAUCAUGUAAUCGUUCAGCUCCCGGAAUGGUUAAGGCCUGUUCGACCGCAGAUCUGGCUGCAUUCGUACAAGCGGGCAGAGGCGAGGACUAAACCUCGCAAGUGGUGCCGU
ACGAUGACCCUUUGGAAGGGUGUUGUUCGUGAGCGUCAGUGUAUGUAAUAAAAACACGUCGUGGGGGAUGCUGUAGAGAAA

======================================================================================

DNA Sequence: TACAGCTTGCTGTACCCGCGTGTAGGAACCCCTTTGGTTCGTCGCACAAATCAATATCGGAACACCACGCAGGTGACCGTGTCAAGCCACCGTTAGGGAGAGGAGCGCACCAGACAAATGTCCTGTTGGCGAAGGACCTGAGAAATCCCGCCCAGCATCACCGTAGCTCGTTCA
ATCTGTTAGCGGAATGGGCGTTCGTACAAAGGCATACAGCTGCATGATCTGGTCCATAGCGCCCTGTGTTCAGAGTAAATA                                                                                                      
RNA Sequence: UACAGCUUGCUGUACCCGCGUGUAGGAACCCCUUUGGUUCGUCGCACAAAUCAAUAUCGGAACACCACGCAGGUGACCGUGUCAAGCCACCGUUAGGGAGAGGAGCGCACCAGACAAAUGUCCUGUUGGCGAAGGACCUGAGAAAUCCCGCCCAGCAUCACCGUAGCUCGUUCA
AUCUGUUAGCGGAAUGGGCGUUCGUACAAAGGCAUACAGCUGCAUGAUCUGGUCCAUAGCGCCCUGUGUUCAGAGUAAAUA


Related Solutions

A molecule of DNA (deoxyribonucleic acid) is 2.31
A molecule of DNA (deoxyribonucleic acid) is 2.31
“Genes” are composed of a substance called: A. Deoxyribonucleic Acid (DNA) B. Carbohydrate C. Protein D....
“Genes” are composed of a substance called: A. Deoxyribonucleic Acid (DNA) B. Carbohydrate C. Protein D. Lipid E. None of the above is correct. Hyperglycemia is defined as: A. high plasma sodium B. low plasma sodium C. low plasma glucose D. high plasma glucose E. None of the above is correct. Which of following statements is true? A. Polar molecules cannot cross (by simple diffusion) the cell membrane. B. Non-polar molecules can cross (by simple diffusion) the cell membrane. C....
A molecule of DNA (deoxyribonucleic acid) lies along a straight line. It is 1.472
A molecule of DNA (deoxyribonucleic acid) lies along a straight line. It is 1.472
Lab Exercise 10 - ISOLATION OF DNA FROM PLANTS Introduction Deoxyribonucleic acid (DNA) is located in...
Lab Exercise 10 - ISOLATION OF DNA FROM PLANTS Introduction Deoxyribonucleic acid (DNA) is located in the nucleus of eukaryotic cells (animals, plants, fungi, and protists). DNA contains information to direct the cell in the manufacture of proteins. Proteins control development, organ function, metabolism, enzymatic reactions, photosynthesis, muscle action, brain activity, and many other cellular processes. DNA is often referred to as the “blueprint for life”. DNA is a polymer composed of the nucleotide bases guanine (G), adenine (A), thymine...
in C a program that counts up from 0 to 20, and reset to 0 after...
in C a program that counts up from 0 to 20, and reset to 0 after 20. needs to count by a press button
write pseudocode for the following problems not c code Pseudocode only Write a C program to...
write pseudocode for the following problems not c code Pseudocode only Write a C program to print all natural numbers from 1 to n. - using while loop Write a C program to print all natural numbers in reverse (from n to 1). - using while loop Write a C program to print all alphabets from a to z. - using while loop Write a C program to print all even numbers between 1 to 100. - using while loop...
C Program and pseudocode for this problem. Write a C program that plays the game of...
C Program and pseudocode for this problem. Write a C program that plays the game of "Guess the number" as the following: Your program choose the number to be guessed by selecting an integer at random in the rang of 1 to 1000. The program then asks the use to guess the number. If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program keeps telling the player "Too High" or...
PLEASE CREATE A PROGRAM IN PSEUDOCODE AND C# Back in my Day!  Kids who grew up in...
PLEASE CREATE A PROGRAM IN PSEUDOCODE AND C# Back in my Day!  Kids who grew up in the late 70s didn’t have a lot of options for video games, but they did have “Choose your own Adventure” books.  These books were cool and let the reader make meaningful decisions.  If they chose choice “A”, they would turn to a page of the book and continue their adventure.  If they chose choice “B”, they would turn to a different page and read a different adventure.  Your...
write pseudocode not c program If- else programming exercises 1.    Write a C program to find...
write pseudocode not c program If- else programming exercises 1.    Write a C program to find maximum between two numbers. 2.    Write a C program to find maximum between three numbers. 3.    Write a C program to check whether a number is negative, positive or zero. 4.    Write a C program to check whether a number is divisible by 5 and 11 or not. 5.    Write a C program to check whether a number is even or odd. 6.    Write...
I need assistance on this problem in Pseudocode and in C++ Program Program 3: Give a...
I need assistance on this problem in Pseudocode and in C++ Program Program 3: Give a baby $5,000! Did you know that, over the last century, the stock market has returned an average of 10%? You may not care, but you’d better pay attention to this one. If you were to give a newborn baby $5000, put that money in the stock market and NOT add any additional money per year, that money would grow to over $2.9 million by...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT