Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class ComputeGCContent {
- private static Double getGCContent(String dna) {
- int gc = 0;
- for (char symbol : dna.toCharArray()) {
- if (symbol == 'G' || symbol == 'C') {
- gc++;
- }
- }
- return (double) gc / dna.length() * 100;
- }
- public static void main(String[] args) throws IOException {
- Scanner in = new Scanner(new File("input.txt"));
- PrintWriter out = new PrintWriter(new File("output.txt"));
- TreeMap<Double, String> data = new TreeMap<Double, String>();
- while (in.hasNextLine()) {
- String id = in.nextLine();
- data.put(getGCContent(in.nextLine()), id);
- }
- out.println(data.lastEntry().getValue() + " " + data.lastKey());
- in.close();
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement