Question: Write a program that uses the Stack, Queue, and Date classes to create a Queue of Stacks of Dates. Your program should have only one

Write a program that uses the Stack, Queue, and Date classes to create a Queue of Stacks of Dates.
Your program should have only one Queue. The Queue will contain inside 4 Stacks.
Each Stack will contain the following objects:
Stack 1(Dates): 12/07/1941,10/12/1492,10/14/1066,05/05/1861,07/04/1776
Stack 2(String): "Attack on Pearl Harbour", "Discovery of America", "Battle of Hastings", "Battle of Puebla", "Declaration of Independence"
Stack 3(Integer): 1,2,3,4,5
Stack 4(Double): Math.PI, Math.E, Math.sqrt(2), Math.sin(Math.PI/4), Math.random()
Add a 6th element to each Stack containing your own name, birthday, SWC ID, and a fictitious GPA.
Your program should push the given values into the 4 Stacks.
Finally, the Stacks must be enqueued in a Queue containing the four Stacks.
The following fragment can be used in main() to start your program:
public static void main(String[] args)
{
Stack[] st = new Stack[4] ;
Queue queue = new Queue();
String[] data1={"Attack on Pearl Harbour", "Discovery of America", "Battle of Hastings", "Battle of Puebla", "Declaration of Independence", "Raul Vargas"};
Date[] data2={new Date("12/07/1941"), new Date("10/12/1492"), new Date("10/14/1066"), new Date("05/05/1861"), new Date("07/04/1776"), new Date("03/28/1969")};
Integer[] data3={1,2,3,4,5,4774};
Double[] data4={Math.PI, Math.E, Math.sqrt(2), Math.sin(Math.PI/4), Math.random(),3.68};
// YOUR CODE GOES HERE:
// Form the Stacks using the proper Stack constructor, add your own data
// and push the values into the Stacks.
// Then enqueue each of the four Stacks and print them as a Queue
System.out.println(queue);
}
A sample run is shown below. Note how my information is shown in Stacks that are inside the Queue:
Raul Vargas Declaration of Independence Battle of Puebla Battle of Hastings Discovery of America Attack on Pearl Harbour
3/28/19697/4/17765/5/186110/14/106610/12/149212/7/1941
477454321
3.680.464572101448295970.70710678118654751.41421356237309512.7182818284590453.141592653589793

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!