Write a program to transcribe DNA to RNA c++

Feb 7th, 2015
DreamIt
Category:
Programming
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.
(997)
School: Boston College
PREMIUM TUTOR

Studypool has helped 1,244,100 students

5 Reviews


Summary
Quality
Communication
On Time
Value
ashleyisgod
Nov 24th, 2016
" Top quality work from this guy! I'll be back! "
Molly_Moon
Nov 2nd, 2016
" AMAZING as always! "
Hemapathy
Oct 10th, 2016
" all I can say is wow very fast work, great work thanks "
BlueOcean
Sep 27th, 2016
" Awesome! Exactly what I wanted. "
kevin12622
Sep 18th, 2016
" Goes above and beyond expectations ! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1831 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