Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Module 4 follow the materials available at Topic - Stacks and Queues. You should

ID: 673787 • Letter: M

Question

Module 4 follow the materials available at Topic - Stacks and Queues. You should have a good understanding of Lists at  Topic - Basic Data structures as a Queue and a Stack are simply implementation of a List with specific properties.

Implement a Stack computer in Javascript (you will turn in a link to your program in JSFiddle). This is a simple computer that keeps a stack, when a number is entered it goes onto the top of the stack. When an operation is entered, the previous 2 numbers are operated on by the operation.

For example

2 [enter] 2

5 [enter]   5 2

* [enter] * 5 2 -> collapses to 10

would leave at 10 at the top of the stack.

The program should use a simple input box, either a text field or prompt and display the contents of the Stack. Please include the Javascript code screenshot and / or temple. Thank you!

Explanation / Answer

var $this = $(this); $('input[type=text][title],input[type=password][title],textarea[title]', $this).each(function (i) { if ($(this).parent().hasClass('prompt_element') == false) { //if prompt already exists then skip $(this).wrap(''); //wrap the element with the prompt element _promptfieldClassName = 'prompt_' + $(this)[0].uniqueID; var _promptfield = '' + $(this).attr('title') + '' //Create the prompt field $(this).before(_promptfield) // Add the prompt field to the Prompt element. The if ($.trim($(this).val()) != '') { //Check if the field has a value $(this).prev().hide(); //Hide the prompt if field has a value }; $('.prompt_field').focus(function () { //If the prompt field get the focus - move to the next field which should be the input $(this).next().focus(); }); $(this).on('keypress paste', function () { //If field has keypress or paste event was triggered $(this).prev().hide(); //hide the prompt field }); $(this).blur(function () { //If leaving the field element if ($.trim($(this).val()) == '') { //Check if the value is empty $(this).prev().show(); //Show the prompt } else { $(this).prev().hide(); //Hide the prompt. This can be initiated by other events if they fill the field. } }); }; }); return $(this);
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote