Write a program to transcribe DNA to RNA c++

Feb 7th, 2015
Price: $5 USD

Question description

 Nesting: L. 2 Application, Code Writing (Biology). Write a program to
transcribe DNA to RNA.  Have the user enter a string called dna, then loop over
it and transcribe each character as follows: A->U, T->A, C->G, G->C. Make sure it is formatted correctly [5]. Example interaction is shown below.
> ACGTGA  // input
< UGCACU  // output
note: I have written a program that will transcribe one into the other, but I can't figure out how to get it to transcribe a string input. This is what I have come up with:

#include <iostream>
using namespace std;

int main() 
  cout << "> ";
  cin  >> dna;
  int a = dna;
  cout << "< ";
    if (a == 'A') cout << 'U';
    else if (a == 'C') cout << 'G';
    else if (a == 'G') cout << 'C';
    else if (a == 'T') cout << 'A';
    cout << " "<< endl;
    return 0;

I'm pretty sure the program has to include a for loop, but I'm uncertain as to how to initialize it and what the condition would be.

Tutor Answer

(Top Tutor) Daniel C.
School: Boston College

Studypool has helped 1,244,100 students

Review from our student for this Answer

Feb 7th, 2015
"Awesome! Exactly what I wanted."
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1819 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors