Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Note : Never hard - code test data in the test program, unless explicitly stated in the assignment. Always allow the user to enter the
Note : Never hardcode test data in the test program, unless explicitly stated in the assignment. Always allow the user to enter the test data using menu option. NO Zip files Part : Stacks The goal of this part is to reinforce the concept of stacks and their implementation. Specifically, this part is to implement few functions to manipulate stack objects of different types. Design and implement the following functions in a test program in file called testStack.java: Function topToButtom takes a stack object of type integer and displays the stack content from the top of the stack to the bottom of the stack. That is the top value is printed first; while the bottom value is printed last. This function does not change the stack content. See example output below. Function buttomToTop takes a stack object of type double and displays the stack content from the bottom of the stack to the top of the stack. That is the bottom value is printed first; while the top value is printed last. This function does not change the stack content. See example output format below, Function flipStack takes a stack object of type string and returns the same stack object with its content being flipped rearranged That is the stack content is changed by this function. For example, if stack Names has the values top to bottom: Ed Tom, Bob, Amy before calling this function, the stack will have the values top to bottom: Amy, Bob, Tom, Ed after the function is executed. See example output format below. Function searchStack takes parameters: a stack object of type integer and an integer target value. It returns true if the target value is on the stack at any place; otherwise it returns false. This function does not change the stack content. See example output format below. Write your main function main as part of file testStack.java and test every function listed above. Make your outputs clean and meaningful, and follow this sample run to format your outputs. Develop a simple menu, below, to allow the user to select and exercise an option: MAIN MENU Test function topToButtom with integer stack Test function buttonToTop with double stack Test function flipStack with string stack Test function searchStack with integer stack Exit program Enter option number: Always redisplay the menu after an option other than option is fully exercised with blank lines before and after the menu. Do Not hardcode test data in the code. Under each option, allow the user to enter the stack values. The menu gives the user control of how to run the program and in any order they wish. Do Not use output labels as input prompts. Test your code with the following sample inputs and format the output as shown below. Notice how output values are linedup after the labels. Testing function topToButtom: Stack content: Function output: Testing function buttomToTop: Stack content: Function output: Testing function flipStack: Testing function searchStack: Stack content: Target value: Function output: false Allow the user to continue to run the program until option is selected use sentinel loop concept
Note : Never hardcode test data in the test program, unless explicitly stated in the assignment.
Always allow the user to enter the test data using menu option.
NO Zip files
Part : Stacks
The goal of this part is to reinforce the concept of stacks and their implementation. Specifically, this part
is to implement few functions to manipulate stack objects of different types.
Design and implement the following functions in a test program in file called testStack.java:
Function topToButtom takes a stack object of type integer and displays the stack content
from the top of the stack to the bottom of the stack. That is the top value is printed first; while the
bottom value is printed last. This function does not change the stack content. See example
output below.
Function buttomToTop takes a stack object of type double and displays the stack content
from the bottom of the stack to the top of the stack. That is the bottom value is printed first; while
the top value is printed last. This function does not change the stack content. See example
output format below,
Function flipStack takes a stack object of type string and returns the same stack object
with its content being flipped rearranged That is the stack content is changed by this function.
For example, if stack Names has the values top to bottom: Ed Tom, Bob, Amy before
calling this function, the stack will have the values top to bottom: Amy, Bob, Tom, Ed after
the function is executed. See example output format below.
Function searchStack takes parameters: a stack object of type integer and an integer
target value. It returns true if the target value is on the stack at any place; otherwise it returns
false. This function does not change the stack content. See example output format below.
Write your main function main as part of file testStack.java and test every function listed above.
Make your outputs clean and meaningful, and follow this sample run to format your outputs. Develop a
simple menu, below, to allow the user to select and exercise an option:
MAIN MENU
Test function topToButtom with integer stack
Test function buttonToTop with double stack
Test function flipStack with string stack
Test function searchStack with integer stack
Exit program
Enter option number:
Always redisplay the menu after an option other than option is fully exercised with blank lines
before and after the menu.
Do Not hardcode test data in the code. Under each option, allow the user to enter the stack values.
The menu gives the user control of how to run the program and in any order they wish. Do Not use
output labels as input prompts. Test your code with the following sample inputs and format the output
as shown below. Notice how output values are linedup after the labels.
Testing function topToButtom:
Stack content:
Function output:
Testing function buttomToTop:
Stack content:
Function output:
Testing function flipStack:
Testing function searchStack:
Stack content:
Target value:
Function output: false
Allow the user to continue to run the program until option is selected use sentinel loop concept
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