Question

Arrays Program 0 (Warm-up. 40 pts): Deoxyribonucleic acid, or DNA, is comprised of four bases: (G)uanine, (C)ytosine, (A)deni
Java source code ?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the solution to the above question. The explanation is done in the code itself in the form of comments (see image) for better line by line explanation and better understanding.

Code:

import java.io.*;
public class as15{                                    // main class
   private static int dna_to_rna(char[] dna) {       // function to change DNA into RNA
    int k=dna.length;                               // geting the lendth of pass paramater dna
   char[] rna=new char[k];                       // creating a new array of char type of length same as dna  
   for (int i = 0; i < dna.length; i++) {            // loop to copy dna into rna and change T to U .
           if(dna[i]=='T')
               rna[i]='U';
           else
               rna[i]=dna[i];
        }
   for (int i = 0; i < rna.length; i++) {            // loop to print the rna
            System.out.print(rna[i]);
        }
       return 0;
   }
    public static void main(String args[])            // main function
    {                                                // string having DNA sequence
       String s = "AGTGAGATTCTGCGACTATGTTAACAGGTTGCATCCTGGCGAGTGGGAGGTCAATGTTGTTAGACTGATATGTCTTTATCTTGAGGCCCGGTGCACGGTCGTTGTGTACAATTCAATCTAGGGTCGGACAGCATTCTCGGGTGTCGCGCCTCCTTTACCACGCGACGCCGTACATGTGAGTGCGAGGGTTCAGAGAGTGCCAAGTATTGGCTTTCCCACTAACGATTTCGGATCTCAAGGCTGCCTTCAGACGGG";
        char[] dna = s.toCharArray();                // converting and storing strind into char array
       for (int i = 0; i < dna.length; i++) {        // printing the dna char array
            System.out.print(dna[i]);
        }
       System.out.println("\n");                    // printing new line
       dna_to_rna(dna);                            // calling the function dna_to_rnam to chang and print the rna.
       }
    }

import java. io. Epublic class as15{ /main class private static int dna to_rna(char [] dna) { k-dna. length char rna-new for

Output:

AGTGAGATTCTGCGACTATGTTAACAGGTTG CATCCTGGCGAGTGGGAGGTCAATGTTGTTAGACTGATATGTCTTTATCTTGAGGC CCGGTG CACGGTCGTTGTGTACAATTCAAT CTAG

Note: If you are still unable to understand, then comment with it and I will be happy to help.

Add a comment
Know the answer?
Add Answer to:
Java source code ? Arrays Program 0 (Warm-up. 40 pts): Deoxyribonucleic acid, or DNA, is comprised...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ***** PSEUDOCODE PLEASE****** ***** PSUDOCODE PLEASE****** Program 0 (Warm-up): Deoxyribonucleic acid, or DNA, is comprised of...

    ***** PSEUDOCODE PLEASE****** ***** PSUDOCODE PLEASE****** Program 0 (Warm-up): Deoxyribonucleic acid, or DNA, is comprised of four bases: (G)uanine, (C)ytosine, (A)denine and (T)hymine.  Ribonucleic acid, or RNA, is different than DNA in that it contains no Thymine; thymine is replaced with something called (U)racil.  For this assignment, you will create an array of 255 characters.  You must start by filling the array with random characters of G, C, A and T.   You must then print out the array.  Next, replace all the instances of Thymine...

  • The deoxyribonucleic acid (DNA) is a molecule that contains the genetic instructions required for the development...

    The deoxyribonucleic acid (DNA) is a molecule that contains the genetic instructions required for the development and functioning of all known living organisms. The basic double-helix structure of the DNA was co-discovered by Prof. Francis Crick, a long-time faculty member at UCSD 0 The DNA molecule consists of a long sequence of four nucleotide bases: adenine (A), cytosine (C), gua- nine (G) and thymine (T). Since this molecule contains all the genetic information of a living organism, geneticists are interested...

  • Please develop a Java program to read in a piece of DNA sequence from a FASTA format sequence fil...

    Please develop a Java program to read in a piece of DNA sequence from a FASTA format sequence file (alternatively you can use the getRandomSeq(long) method of the RandomSeq class to generate a piece of DNA sequence), and then print out all the codons in three forward reading frames. Design a method called codon() that can be used to find all the codons from three reading frames. The method will take in an argument, the reading frame (1, 2, or...

  • DNA DNA Replication: ONA Because DNA Is the ge m Tumes and heart e ine in...

    DNA DNA Replication: ONA Because DNA Is the ge m Tumes and heart e ine in process called DNA curs in the nucleus of s acest FS Parent strand Parent strand Newly replicated DNA Newly replicated DNA- SA0 Daughter DNA molecule Daughter DNA molecule Figure 8.2: Overview of DNA replication and illustration of complementary base pairing. DNA must replicate before cell division so that each new daughter cell receives an exact copy of the parent DNA. 1. Replication begins when...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT