Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
2.1 kB
69
Indexable
Never
import java.io.*;
import java.util.*;

class Operator {
    String name;
    String ssn;
    String dept;
    int salary;

    public Operator(String name, String ssn, String dept, int salary) {
        this.name = name;
        this.ssn = ssn;
        this.dept = dept;
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Operator{" +
                "name='" + name + '\'' +
                ", ssn='" + ssn + '\'' +
                ", dept='" + dept + '\'' +
                ", salary=" + salary +
                '}';
    }
}

class OperatorImplementation {
    public Operator getOperatorInfo(String str) {
        int indexOfAtTheRate = str.indexOf("@");
        int indexOfHyphen = str.indexOf("-");
        int indexOfHash = str.indexOf("#");
        
        String name = str.substring(0, indexOfAtTheRate);
        String ssn = str.substring(indexOfAtTheRate + 1, indexOfHyphen);
        String dept = str.substring(indexOfHyphen + 1, indexOfHash);
        int salary = Integer.parseInt(str.substring(indexOfHash + 1));
        
        Operator e = new Operator(name, ssn, dept, salary);

        return e;
    }

    public String getOperatorLevel(Operator e) {
        int level = Integer.parseInt(e.ssn.substring(e.ssn.length() - 3));
    
        System.out.println(level);

        if (level > 50 && level <= 100) {
            return "L1";
        }
        else if (level > 101 && level <= 150) {
            return "L2";
        }
        else if (level > 151 && level <= 200) {
            return "L3";
        }
        else if (level > 201 && level <= 250) {
            return "L4";
        }

        return "NA";
    }
}

class Source {
    public static void main(String args[]) throws Exception {
        Scanner obj = new Scanner(System.in);
        String input = obj.nextLine();

        OperatorImplementation oi = new OperatorImplementation();
        Operator op = oi.getOperatorInfo(input);

        System.out.println(oi.getOperatorLevel(op));
    }
}