Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class organizingTasks {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int priority[] = {2, 3, 1, 1, 3, 2, 1};
- String assignment[] = {"English commentary", "Art and craft", "Reading about global warming", "Algorithm on eclipse", "Trigonometry exercises", "Presentation on HL CS", "French vocabulary"};
- int topRate;
- int temp1;
- String temp2;
- for(int i=0; i<priority.length; i++)
- {
- topRate = i;
- for(int j=i+1; j<priority.length; j++)
- {
- if(priority[topRate]<priority[j])
- topRate = j;
- } //end of inner loop
- if(topRate != i)
- {
- temp1 = priority[i];
- priority[i] = priority[topRate];
- priority[topRate] = temp1;
- temp2 = assignment[i];
- assignment[i] = assignment[topRate];
- assignment[topRate] = temp2;
- }
- }
- for(int i=0; i<priority.length; i++)
- System.out.println("Task " + assignment[i] + ", priority: " + priority[i]);
- } //class ends
- } //program ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement