AQueueDriver - System.out.println("The value

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 import java.util.* public class AQueueDriver { public static void main(String[] args){ AQueue<Integer> intQueue = new AQueue<Integer>(5) A System.out.println("Choose one of the following operations:") System.out.println("-enqueue/add (enter letter a)") System.out.println("-dequeue/delete (enter letter d)") System.out.println("-check if the list is empty (enter letter e)") System.out.println("-quit (enter letter q)") char userInput = ' ' int temp Scanner in = new Scanner( S while(userInput != 'q'){ System.out.print("Enter a menu option: ") userInput = u switch(userInput){ case 'a': System.out.print("Enter the value to add: ") if(in.hasNextInt()){ temp = in.nextInt() intQueue.enqueue(temp)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.println(&quot;The value &quot;+temp+&quot; has been enqueued.&quot;) } else{ System.out.println(&quot;Invalid input. ..must be an integer!&quot;) } break case 'd': try{ System.out.println(&quot;The value &quot;+intQueue.dequeue()+&quot; has been dequeued.&quot;) } catch(AQueue.MyException e){ System.out.println(&quot;Invalid Operation: The Queue is empty&quot;) } break case 'e': if(intQueue.isEmpty()) System.out.println(&quot;Empty&quot;) else System.out.println(&quot;Not Empty&quot;) break case 'p': intQueue.printArray() break case 'q': while(!intQueue.isEmpty()){ System.out.println(&quot;The value &quot;+intQueue.dequeue()+&quot; has been dequeued.&quot;) Sheet1 Page 2 } break default: System.out.println(&quot;Error enter a valid menu choice!&quot;) } } } }...
View Full Document

This lab report was uploaded on 04/21/2008 for the course CSC 103 taught by Professor Franklin during the Spring '07 term at Cal Poly.

Page1 / 2

AQueueDriver - System.out.println(&amp;amp;quot;The value

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online