Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5.11 DNA Batch Analysis Write a complete C++ program to analyze a set of DNA str

ID: 670436 • Letter: 5

Question

5.11 DNA Batch Analysis

Write a complete C++ program to analyze a set of DNA strands input from the keyboard. For each strand, output the strand followed by validity, CG percentage, and overall stability. For example, given this input sequence:

Your program should output the following:

In terms of overall stability, if the CG percentage is 75 or greater, than the DNA strand is considered "highly stable". If the CG percentage is < 75 but 50 or greater, it's considered "stable". Less than 50 but 25 or greater is considered "less stable". And a CG percentage < 25 is considered "unstable".

Recall that validity and CG percentage were the focus in lab this week (lab-05). You will also need a loop to input and process the strands one by one. Here's a skeleton loop structure to build upon:

Explanation / Answer

#include<iostream>

#include<string>
using namespace std;

int main()
{
string DNA;

cin >> DNA;
int flag=1,count=0;
double percent;
while (DNA != "#")
{
  
for(int i=0;i<DNA.length();i++){
if(DNA[i]!='A'&&DNA[i]!='C'&&DNA[i]!='T'&&DNA[i]!='G'){

flag=0;
}
if(DNA[i]=='C'||DNA[i]=='G'){

count++;
}
}
percent=((double)count/(double)DNA.length())*100;

if(flag==1){
if(percent>=75){
cout<<DNA<<": valid "<<percent<<"% highly stable"<<endl;
}else if(percent>=50){
cout<<DNA<<": valid "<<percent<<"% stable"<<endl;
}else if(percent>=25){
cout<<DNA<<": valid "<<percent<<"% less stable"<<endl;
}else if(percent<25){
cout<<DNA<<": valid "<<percent<<"% unstable"<<endl;
}
}else{
cout<<DNA<<" invalid"<<endl;
}

cin >> DNA; // read next DNA strand:
}

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote