Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Scanner;
- public class cheaters {
- static class Person implements Comparable<Person> {
- public String name;
- public double val;
- public double grade;
- Person(String n, double v, double g) {
- name = n;
- val = v;
- grade = g;
- }
- @Override
- public int compareTo(Person arg0) {
- if (val < arg0.val)
- return 1;
- else if (val > arg0.val)
- return -1;
- else
- return 0;
- }
- public String toString() {
- return name + ": " + val + ", " + grade;
- }
- }
- public static void main(String[] args) throws FileNotFoundException {
- Scanner s = new Scanner(new File("/studentdata.dat"));
- String key1 = s.nextLine();
- String key2 = s.nextLine();
- int max = 0;
- ArrayList<Person> people = new ArrayList<Person>();
- for (int i = 0; i < 10000; i++) {
- char test = s.next().trim().charAt(0);
- String name = s.next().trim() + " " + s.next().trim();
- name = name.substring(0, name.length() - 1);
- double score = s.nextDouble();
- String answers = s.nextLine().trim();
- double num = 0;
- double den = 0;
- for (int j = 0; j < 200; j++) {
- if (test == 'A') {
- if (answers.charAt(j) != key1.charAt(j)) {
- den++;
- if (answers.charAt(j) == key2.charAt(j)) {
- num++;
- }
- }
- }
- if (i % 2 == 1) {
- if (answers.charAt(j) != key2.charAt(j)) {
- den++;
- if (answers.charAt(j) == key1.charAt(j)) {
- num++;
- }
- }
- }
- }
- people.add(new Person(name, num / den * 100.0, score));
- }
- ArrayList<String> cheaters = new ArrayList<String>();
- for (int i = 0; i < 10000; i++) {
- Person p = people.get(i);
- if (p.val >= 60.0 && p.grade <= 75.0) // Experimental, mess around with these until cheaters.size() == 5
- cheaters.add(p.name.split(" ")[1]);
- }
- Collections.sort(cheaters);
- String out = "";
- for (String c : cheaters)
- out += c + ","; // This only runs 5 times, don't worry
- out = out.substring(0, out.length() - 1);
- System.out.println(out);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement