Advertisement
JeffGrigg

KJPMPRO

Sep 7th, 2018
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.85 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class KJPMPRO {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         final List<CollegeDepartment> departments = new ArrayList<>();
  8.         Scanner scan = new Scanner(System.in);
  9.  
  10.         for (int q = 1; q <= 6; q++) {
  11.             System.out.println("Enter College Department name");
  12.             String departmentName = scan.next();
  13.             System.out.println("Choreography plss input 1% to 40% only");
  14.             int choreography = scan.nextInt();
  15.             System.out.println("Execution plss input 1% to 30% only");
  16.             int execution = scan.nextInt();
  17.             System.out.println("Concept representation plss input 1% to 20% only");
  18.             int concept = scan.nextInt();
  19.             System.out.println("Appropriateness of props plss input 1% to 10% only");
  20.             int appropriateness = scan.nextInt();
  21.  
  22.             departments.add(new CollegeDepartment(departmentName, choreography, execution, concept, appropriateness));
  23.         }
  24.  
  25.         departments.sort(new Comparator<CollegeDepartment>() {
  26.             @Override
  27.             public int compare(final CollegeDepartment left, final CollegeDepartment right) {
  28.                 return right.getScore() - left.getScore();
  29.             }
  30.         });
  31.  
  32.         int nth = 0;
  33.         for (final CollegeDepartment collegeDepartment : departments) {
  34.             ++nth;
  35.             String postfix = "th";
  36.             if (nth == 1) {
  37.                 postfix = "st";
  38.             } else if (nth == 2) {
  39.                 postfix = "nd";
  40.             } else if (nth == 3) {
  41.                 postfix = "rd";
  42.             }
  43.             System.out.println(nth + postfix + " is '" + collegeDepartment.getDepartmentName() + "' with " + collegeDepartment.getScore());
  44.         }
  45.     }
  46.  
  47.     private static class CollegeDepartment {
  48.         String _departmentName;
  49.         int _choreography;
  50.         int _execution;
  51.         int _concept;
  52.         int _appropriateness;
  53.  
  54.         public CollegeDepartment(String departmentName, int choreography, int execution, int concept, int appropriateness) {
  55.             _departmentName = departmentName;
  56.             _choreography = choreography;
  57.             _execution = execution;
  58.             _concept = concept;
  59.             _appropriateness = appropriateness;
  60.         }
  61.  
  62.         public int getScore() {
  63.             return _choreography + _execution + _concept + _appropriateness;
  64.         }
  65.  
  66.         public String getDepartmentName() {
  67.             return _departmentName;
  68.         }
  69.  
  70.         public int getChoreography() {
  71.             return _choreography;
  72.         }
  73.  
  74.         public int getExecution() {
  75.             return _execution;
  76.         }
  77.  
  78.         public int getConcept() {
  79.             return _concept;
  80.         }
  81.  
  82.         public int getAppropriateness() {
  83.             return _appropriateness;
  84.         }
  85.     }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement