Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NEED HELP Write a method called stackSum that returns an int and has no parameters which will find the sum of a stack using a
NEED HELP
"Write a method called stackSum that returns an int and has no parameters which will find the sum of a stack using a recursive technique and leave the stack unchanged. Test the method in a driver program with the following items pushed onto a stack in the following hardcoded order: -6, 4, 2, 10, 8. The output of the program should display the sum in a message to the console. Assume the method is a member of a linked stack class called LinkedStack that has a private data member: top, and methods: getInfo() and getLink(). The data member top is of type: LSNode (linked stack node), and each LSnode has data members: info and link-" The following rubric will be used: 1. Create the basic template common to all Java programs. 2. Give the correct signature for the specified method/function. 3. Access the calling object's stack. 4. Effectively accesses the data members and methods. 5. Implement a base case and recursive case in the solution. 6. Effectively return the correct sum of a stack using recursion. 7. Leave the calling object's stack unchanged. 8. Test the recursive function/method using a main driver. 9. Check the program for errors and omissions and debug. 10. Successfully execute the file with the appropriate output to the console. A score of 5, for example, would mean the program demonstrated 5 out of the 10 objectivesStep 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