Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

DNA exercise

import java.util.Scanner;

public class DNA {
    public static void main(String[] args) {
        String sequence = StdIn.readString();
        String complementary = "";

        for (int i = 0; i < sequence.length(); i++) {
            char nucleotide = sequence.charAt(i);

            if (nucleotide=='A'){
                complementary += 'T';
            }else if (nucleotide=='T') {
                complementary += 'A';
            }else if (nucleotide=='C'){
                complementary += 'G';
            }else if (nucleotide=='G'){
                complementary += 'C';
            }
        }
        System.out.println(complementary);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: editable java jcombobox 
Java :: a to double 
Java :: java preprocessor example 
Java :: What is accept() method in networking 
Java :: byte array to zip java 
Java :: Java Advantages of Anonymous Classes 
Java :: Add space to the left and right sides of a cell 
Java :: check if two characters are equal java 
Java :: number of zeros in a binary array 
Java :: copy array of objects in java 
Java :: findng and replacing duplicate values in an array 
Java :: java.lang.noclassdeffounderror even though class is present 
Java :: exception in thread "main" java.lang.arrayindexoutofboundsexception: 10 
Java :: difido 
Java :: java png obj animate image size 
Java :: how to run the war file in Apache Tomcat/8.5.59 THROUGH SPRING 
Java :: print out list of letters a to z java 
Java :: bipredicate in java 
Java :: aspectj after returning 
Java :: using ..replace() in jShell/java 
Java :: We would like to make a member of a class can access in all subclasses regardless of what package the subclass is in. Which one of the following keywords would achieve this? 
Java :: implicit type casting in java 
Java :: java random number generator 6 
Java :: intent from notification with extra to activity 
Java :: RTC_WAKEUP 
Java :: connect 2 package in android 
Java :: customize the androidx.appcompat.widget.SearchView site:stackoverflow.com 
Java :: okhttp Sending and Receiving Network Requests 1 
Java :: java gson get object without class 
Java :: max head java 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =