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...
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...
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 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...
For this assignment you will develop pseudocode and write a C++ program for a simple calculator....
For this assignment you will develop pseudocode and write a C++ program for a simple calculator. You will create both files in Codio. Put your pseudocode and C++ code in the files below. PSEUDOCODE FILE NAME: Calculator.txt C++ SOURCE CODE FILE NAME : Calculator.cpp DESCRIPTION: Write a menu-driven program to perform arithmetic operations and computations on a list of integer input values. Present the user with the following menu. The user will choose a menu option. The program will prompt...
6. Write a program in C programming (compile and run), a pseudocode, and draw a flowchart...
6. Write a program in C programming (compile and run), a pseudocode, and draw a flowchart for each of the following problems: a) Obtain three numbers from the keyboard, compute their product and display the result. b) Obtain two numbers from the keyboard, and determine and display which (if either) is the smaller of the two numbers. c) Obtain a series of positive numbers from the keyboard, and determine and display their average (with 4 decimal points). Assume that the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT