So I developed this code so that I would have a program that can randomly generate a DNA sequence.
These are my questions:
1) how can i get the random number sequence to develop in a string?
2) how can i then multiplate the string so that the "A"s are replaced by "G"s or what not?
3) In the RNA portion of it: is there another way to program the yes or no answer responses instead of using if statements?
Also if there is anyother comment on my code its appreciated
if any question needs clarifying let me know
thank you so much in advance
here is my code
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
cout << "The Program Will First Generate a DNA Sequence:" << endl;
cout << endl;
{
srand((unsigned)time(0));
int random_integer;
int lowest=1, highest=4;
int range=(highest-lowest)+1;
char letters;
string sequence;
letters = 'A','T','C','G';
for(int index=0; index<20; index++)
{
random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
random_integer = rand() % 4;
if(random_integer == 0)
letters = 'A';
if(random_integer == 1)
letters = 'T';
if(random_integer == 2)
letters = 'C';
if(random_integer == 3)
letters = 'G';
cout << letters << endl;
}
}
{
cout<< endl;
int answer;
int Y;
int N;
cout<< "Would You Like to Generate a RNA Sequence?(Y/N)"<< endl;
cin>> answer;
cout<< endl;
{
if (answer = Y)
{
srand((unsigned)time(0));
int random_integer;
int lowest=1, highest=4;
int range=(highest-lowest)+1;
char letters;
string sequence;
letters = 'A','C','G','U';
for(int index=0; index<20; index++)
{
random_integer =lowest+int(range*rand()/(RAND_MAX + 1.0));
random_integer = rand() % 4;
if(random_integer == 0)
letters = 'A';
if(random_integer == 1)
letters = 'U';
if(random_integer == 2)
letters = 'C';
if(random_integer == 3)
letters = 'G';
cout << letters << endl;
}
}
if(answer = N)
{
cout << "No Sequence Was Generated." << endl;
}
}
}
return 0;
}