Question

In: Computer Science

C++ program, include comments stating what each part of code does please. I want to be...

C++ program, include comments stating what each part of code does please. I want to be able to understand it so I'll be more knowledgeable in the future. The program is multiple files(transcribe_dna_to_rna.h file, transcribe_dna_to_rna.cpp file, main.cpp file and loops_strings_test.cpp). After the directions I also included any starter code or comments left by my professor within the files to aide us.

Directions:

In folder 05_loops_strings write prototype and definition for string value - return function transcribe_dna_into_rna with a string parameter that returns the rna string. Write the required unit test(s) in folder 05_loops_strings_test. Main program flow: No loop. Use the given string as function argument call transcribe_dna_into_rna function and display the output.

transcribe_dna_to_rna.h

/*
Create a function transcribe_dna_into_rna with a dna const reference string parameter that returns a string.
*/

transcribe_dna_to_rna.cpp

//Write include statements
/*
An RNA string is a string formed from the alphabet containing 'A', 'C', 'G', and 'U'.
Given a DNA string t corresponding to a coding strand, its transcribed RNA string u is formed by replacing
all occurrences of 'T' in t with 'U' in u.
Given: A DNA string
Return: The transcribed RNA string of the DNA string
Examle:
dna_string: GATGGAACTTGACTACGTAAATT
transcribe_dna_into_rna("GATGGAACTTGACTACGTAAATT");
returns:
GAUGGAACUUGACUACGUAAAUU
*/

main.cpp

//Write include statements
//Write using statements
/*
No loop.
Use the string "GATGGAACTTGACTACGTAAATT" call the transcribe_dna_into_rna function and display the result
*/
int main()
{
return 0;
}

loops_strings_test.cpp

#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
//Write include statements
/*
Write test case for transcribe dna to rna with string:
"GATGGAACTTGACTACGTAAATT" returns GAUGGAACUUGACUACGUAAAUU
*/

Solutions

Expert Solution

// transcribe_dna_to_rna.h

//function for converting DNA to RNA

string transcribe_dna_into_rna(string t){

string u = "";

//iterating over whole DNA string t to construct RNA string u

for(int i=0;i<t.length();i++){

//checking if character at position i is T which needs to be converted to U

if(t[i]=='T'){

//if T exists at position i then we add U in place of T

u += 'U';

}else{

//if any other character appears in other than T then we add the correcponding character to RNA string

u += t[i];

}

}

return u;

}

// main.cpp

#include<iostream>

#include "transcribe_dna_to_rna.h"

using namespace std;

int main(){

//calling function transcribe_dna_into_rna to convert DNA to RNA;

string rna = transcribe_dna_into_rna("GATGGAACTTGACTACGTAAATT");

cout<<rna<<endl;

return 0;

}

// loops_strings_test.cpp

#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file

#include "catch.hpp"

#include "transcribe_dna_to_rna.h" //including our header file

//writing test case for the function RNA to DNA

TEST_CASE("Testing DNA to RNA function") {

//calling the function and then comparing with the correct data, REQUIRE ensures that the condition is matched else the test case will fail

REQUIRE(transcribe_dna_into_rna("GATGGAACTTGACTACGTAAATT").compare("GAUGGAACUUGACUACGUAAAUU")==0)

}

Hope this helps. Please upvote. thanks.


Related Solutions

C++ program, include comments stating what each part of code does please. I want to be...
C++ program, include comments stating what each part of code does please. I want to be able to understand it so I'll be more knowledgeable in the future. The program is multiple files(fibonacci.h file, fibonacci.cpp file, main.cpp file and loops_simple_data_test.cpp). After the directions I also included any starter code or comments left by my professor within the files to aide us. Directions: In folder 04_loops_simple_data write prototype and definition for string value - return function get_fibonacci with an int parameter...
I want a unique c++ code for the following. PLEASE HIGHLIGHT THESE FUNCTIONS WITH COMMENTS ....
I want a unique c++ code for the following. PLEASE HIGHLIGHT THESE FUNCTIONS WITH COMMENTS . Add the following functions to the class arrayListType: Then, update the main function to test these new functions. removeAll - which removes ALL of the instances of a value in the list min - which returns the minimum value in the list max - which returns the maximum value in the list arrayListType.h : #ifndef H_arrayListType #define H_arrayListType class arrayListType { public: bool isEmpty()...
A C++ question: I want to indent the code of this C++ program: #include<iostream> #include<cstring> using...
A C++ question: I want to indent the code of this C++ program: #include<iostream> #include<cstring> using namespace std; int lastIndexOf(char *s, char target) { int n=strlen(s); for(int i=n-1;i>=0;i--) { if(s[i]==target) { return i; } } return -1; } void reverse(char *s) { int n=strlen(s); int i=0,j=n-1; while(i<=j) { char temp=s[i]; s[i]=s[j]; s[j]=temp; i++; j--; } return; } int replace(char *s, char target, char replacementChar) { int len=strlen(s); int total=0; for(int i=0;i<len;i++) { if(s[i]==target) { s[i]=replacementChar; total+=1; } } return total;...
Please Complete this C Code using the gcc compiler. Please include comments to explain each added...
Please Complete this C Code using the gcc compiler. Please include comments to explain each added line. /*This program computes the Intersection over Union of two rectangles as a percent: IoU = [Area(Intersection of R1 and R2) * 100 ] / [Area(R1) + Area(R2) - Area(Intersection of R1 and R2)] The answer will be specified as a percent: a number between 0 and 100. For example, if the rectangles do not overlap, IoU = 0%. If they are at the...
I need to complete this C++ program. The instructions are in the comments inside the code...
I need to complete this C++ program. The instructions are in the comments inside the code below: ------------------------------------------------------------------------- Original string is: this is a secret! Encypted string is: uijt!jt!b!tfdsfu" Decrypted string is: this is a secret! //Encoding program //Pre-_____? //other necessary stuff here int main() { //create a string to encrypt using a char array cout<< "Original string is: "<<string<<endl; encrypt(string); cout<< "Encrypted string is: "<<string<<endl; decrypt(string); cout<<"Decrypted string is: "<<string<<endl; return 0; } void encrypt(char e[]) { //Write implementation...
Assembly language: please comment on every line of code explaining each part. include head comments describing...
Assembly language: please comment on every line of code explaining each part. include head comments describing what your program does. Assignment 3A - A program that adds and subtracts 32-bit numbers After installing the assembler on the computer, enter the following program, save it, assemble it and run it. Do not forget to add a comment with your name in it. You will hand in a listing (e.g., addsum.asm) that should include your name ________________________________________ TITLE Add and Subtract (AddSum.asm)...
1. Write code in mips that will play battleships. Include comments in code on what each...
1. Write code in mips that will play battleships. Include comments in code on what each part is doing.
Please comments this C++ code and show screenshots of the outputs main.cpp #include<iostream> #include<vector> #include<string> #include"BST.h"...
Please comments this C++ code and show screenshots of the outputs main.cpp #include<iostream> #include<vector> #include<string> #include"BST.h" #include"BST.cpp" using namespace std; std::vector<std::string> tokenize(char line[]) {    std::vector<std::string> tok;        std::string word = "";        for (int i = 0; i < strlen(line); i++)        {            if (i == strlen(line) - 1)            {                word += line[i];                tok.push_back(word);                return tok;       ...
i need C++ program with possible comments what is going on,(a) Write a program that reads...
i need C++ program with possible comments what is going on,(a) Write a program that reads a char as input, and determines if it is a lowercase letter, uppercase letter, a digit or something else (call the last one a special character).
I NEED THIS CODE FOR C++ USING MONITORS PLEASE #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include...
I NEED THIS CODE FOR C++ USING MONITORS PLEASE #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #define THREADS 10 // Number of Thread //bridge declared with array of character and integer value void Bridge(char array[], int value); // Global Variable int North = 1; //For North Number int South = 1; //For South Number pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; // Setting Up MUTEX for lock //Thread for North farmer void NorthFarmer(){ pthread_mutex_lock(&mutex1); char array[5] = "North"; // North printf("%s Tunbridge...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT