Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 Stacks.
Each Stack will contain the following objects:
Stack Dates:
Stack String: "Attack on Pearl Harbour", "Discovery of America", "Battle of Hastings", "Battle of Puebla", "Declaration of Independence"
Stack Integer:
Stack Double: Math.PI Math.E Math.sqrt Math.sinMathPI Math.random
Add a th element to each Stack containing your own name, birthday, SWC ID and a fictitious GPA.
Your program should push the given values into the 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 mainString args
Stack st new Stack ;
Queue queue new Queue;
String dataAttack on Pearl Harbour", "Discovery of America", "Battle of Hastings", "Battle of Puebla", "Declaration of Independence", "Raul Vargas";
Date datanew Date new Date new Date new Date new Date new Date;
Integer data;
Double dataMathPI Math.E Math.sqrt Math.sinMathPI Math.random;
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.printlnqueue;
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started