Results 1 to 2 of 2
- 04-16-2012, 02:09 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 3
- Rep Power
- 0
Implementing a Priority queue with two values.Can you store an array in a priority q?
Hi this is for a homework assignment I don't want answers and I am not looking for it, I just want help to be a better programmer. I have questions and don't know where to look. Ok I will start explaining what my problem is. Basically my program is a "CPU SIM". It is not to fancy it just takes a name a priority and then a size variable and prints that off. For the value of the Size variable it prints out it is starting a new time slice. The problem is that my program needs to build an the priority queue then print off the values in the priority queue until there are no more priority left in the queue. It gets its commands from a text file that reads
the name varaible is shut down, and the length is how many time slices it should print out.What I have programmed so far makes three variables for name, length, and priority. My plan is to then run it through a builder to make a queue then after the builder is done have a another class that will have it print out what i need to print out. I need help figuring out my static classes and how to implement my static Variable ADT.add job Internet with length 6 and priority 4
add job Launchcode with length 3 and priority 3
add job Facebook with length 2 and priority 5
add job explorer with length 1 and priority 2
add job shutdown with length 5 and priority 1
My code is bellow. Please ask any question I will answer immediately please help me!
Java Code:package cpusim; import java.io.*; import java.util.Scanner; public class Cpusim { public int x = 0; public boolean T; /** * @param args the command line arguments */ public static void main(String[] args) throws FileNotFoundException, IOException { String[] myarray; String fileName; FileInputStream in = new FileInputStream("input.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; myarray = new String[5]; for (int j = 0; j < myarray.length; j++) { myarray[j] = br.readLine(); } in.close(); for (int i = 0; i < myarray.length; i++) { String S=myarray[i]; String[] X = S.split(" "); String name = X[3]; String p= X[6]; String n = X[9]; System.out.print(name+" "+p+" "+n+" "+" "); int length = Integer.parseInt(p); int priority =Integer.parseInt( n ); builder(name,length,priority); } } public static void builder(String name, int length, int priority) { }Last edited by Fubarable; 04-16-2012 at 02:32 AM. Reason: request for PM's deleted
- 04-16-2012, 10:40 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,589
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Priority Queue Implementation
By cylus99 in forum New To JavaReplies: 1Last Post: 12-20-2011, 10:48 PM -
Priority Queue
By fam2315 in forum New To JavaReplies: 5Last Post: 06-29-2011, 03:10 AM -
Priority Queue with explicit priority
By lsk in forum Advanced JavaReplies: 4Last Post: 06-10-2011, 07:16 PM -
Priority Queue
By Suende in forum New To JavaReplies: 19Last Post: 04-25-2011, 08:46 AM -
Priority Queue Question
By Taz_84 in forum New To JavaReplies: 0Last Post: 01-29-2009, 03:23 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks