Advertisement
oona

organizing tasks

Jan 22nd, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. public class organizingTasks {
  2.  
  3.     public static void main(String[] args) {
  4.         // TODO Auto-generated method stub
  5.        
  6.         int priority[] = {2, 3, 1, 1, 3, 2, 1};
  7.         String assignment[] = {"English commentary", "Art and craft", "Reading about global warming", "Algorithm on eclipse", "Trigonometry exercises", "Presentation on HL CS", "French vocabulary"};
  8.         int topRate;
  9.         int temp1;
  10.         String temp2;
  11.        
  12.         for(int i=0; i<priority.length; i++)
  13.         {
  14.             topRate = i;
  15.            
  16.             for(int j=i+1; j<priority.length; j++)
  17.             {
  18.                 if(priority[topRate]<priority[j])
  19.                    
  20.                     topRate = j;
  21.                    
  22.             } //end of inner loop
  23.            
  24.             if(topRate != i)
  25.             {
  26.                 temp1 = priority[i];
  27.                 priority[i] = priority[topRate];
  28.                 priority[topRate] = temp1;
  29.                
  30.                 temp2 = assignment[i];
  31.                 assignment[i] = assignment[topRate];
  32.                 assignment[topRate] = temp2;
  33.                
  34.             }
  35.         }
  36.        
  37.         for(int i=0; i<priority.length; i++)
  38.             System.out.println("Task " + assignment[i] + ", priority: " + priority[i]);
  39.            
  40.     } //class ends
  41.  
  42. } //program ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement