Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dopolnitelni_casovi.linkedlists;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- /**
- * ----------------------------
- * Project: APS
- * Package: dopolnitelni_casovi.linkedlists
- * Created on: 27.5.2016, 23:41
- * IDE: IntelliJ IDEA
- * ----------------------------
- * Author: Damjan Miloshevski
- * Web: http://damjanmiloshevski.mk/
- * Phone: +389 (0)78 566 409
- * E-mail: d.miloshevski@gmail.com; contact@damjanmiloshevski.mk
- * Skype: damjan.milosevski
- * LinkedIn: https://mk.linkedin.com/in/damjanmiloshevski
- * GitHub: https://github.com/damsii
- * Bitbucket: https://bitbucket.org/dam_si
- */
- public class SLLKompanija {
- public static void main(String[] args) throws IOException {
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- List<Vraboten> kompanija = new ArrayList<>();
- try {
- int N = Integer.parseInt(in.readLine());
- for (int i = 0; i < N; i++) {
- int id = Integer.parseInt(in.readLine());
- int plata = Integer.parseInt(in.readLine());
- kompanija.add(new Vraboten(id, plata));
- }
- int plata = Integer.parseInt(in.readLine());
- List<Vraboten> novi = removeLowerThan(kompanija, plata);
- Collections.sort(novi, Collections.reverseOrder());
- if (novi.isEmpty()) {
- System.out.println("nema");
- } else {
- for (Vraboten v : novi) {
- System.out.println(v.toString());
- }
- }
- } catch (NumberFormatException e) {
- System.err.println("Pogresen vlez!");
- }
- }
- static List<Vraboten> removeLowerThan(List<Vraboten> employees, int amount) {
- List<Vraboten> company = new ArrayList<>();
- for (Vraboten vraboten : employees) {
- if (vraboten.getPlata() >= amount) {
- company.add(vraboten);
- }
- }
- return company;
- }
- }
- class Vraboten implements Comparable<Vraboten> {
- private int ID;
- private int plata;
- public Vraboten(int ID, int plata) {
- this.ID = ID;
- this.plata = plata;
- }
- public int getID() {
- return ID;
- }
- public int getPlata() {
- return plata;
- }
- @Override
- public String toString() {
- return String.format("%d %d", ID, plata);
- }
- @Override
- public int compareTo(Vraboten o) {
- return Integer.compare(ID, o.ID);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement