Write a Java program and screenshot of the output using Stack class to show the following points: a. Create three empty stacks named stackOne, stackTwo and stackThree respectively. b. Push the numbers [a, b, c, d] "for example [7, 5, 8, 22]" into stackOne and [w, x, y, z] "for example [5, 4, 2, 11]" into stackTwo. (Note: value of the numbers [a,b,c,d, etc] for each of the student should be different) c. Pop the top number of stackOne and top number of stackTwo and add them. Then, push the addition result into stack Three. d. Pop the top number of stackOne and top number of stackTwo and subtract them. Push the result of subtraction into stackThree. e. Print StackOne, stackTwo and stackThree. f. Print the largest number in stackThree

icon
Related questions
Question
Write a Java program and screenshot of the output using Stack class to show
the following points:
a. Create three empty stacks named stackOne, stackTwo and stackThree
respectively.
b. Push the numbers [a, b, c, d] "for example [7, 5, 8, 22]" into stackOne
and [w, x, y, z] "for example [5, 4, 2, 11]” into stackTwo. (Note: value of
the numbers [a,b,c,d, etc] for each of the student should be different)
c. Pop the top number of stackOne and top number of stackTwo and add
them. Then, push the addition result into stack Three.
d. Pop the top number of stackOne and top number of stackTwo and
subtract them. Push the result of subtraction into stackThree.
e. Print StackOne, stackTwo and stackThree.
f. Print the largest number in stack Three
Transcribed Image Text:Write a Java program and screenshot of the output using Stack class to show the following points: a. Create three empty stacks named stackOne, stackTwo and stackThree respectively. b. Push the numbers [a, b, c, d] "for example [7, 5, 8, 22]" into stackOne and [w, x, y, z] "for example [5, 4, 2, 11]” into stackTwo. (Note: value of the numbers [a,b,c,d, etc] for each of the student should be different) c. Pop the top number of stackOne and top number of stackTwo and add them. Then, push the addition result into stack Three. d. Pop the top number of stackOne and top number of stackTwo and subtract them. Push the result of subtraction into stackThree. e. Print StackOne, stackTwo and stackThree. f. Print the largest number in stack Three
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer