Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PART1: Objectives: After finishing the lab4 part 1, you can: -handle the stack structure when applying push and pop operations to add or fetch and

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

PART1: Objectives: After finishing the lab4 part 1, you can: -handle the stack structure when applying push and pop operations to add or fetch and delete the nodes -handle the queue structure when applying enque and deque operations to add or fetch and delete the nodes.

Requirement Statement: Develop the pseudo-code and draw the UML of data type classes of the project named Create the project SP2017LAB4_PART1 that using the Restricted Data Structure (EmployeeStack or EmployeeQueue) and the driver class should be SP2017LAB4_RestrictedStructureDemoWithEmployee) The EmployeeStack or EmployeeQueue will keep employees or employees with title.

The application will allow users to select to work with either Stack or Queue. When finishing with one, the application allow users to continue to select and work with the other structure until users want to exit

For Stack or Queue, do the following steps in order: 1. Define the structure 2. Allow users to insert 5 nodes (either Employee or TitleEmployee) 3. Show all 5 employees/titleEmployees that are inserted 4. Delete 2 nodes 5. Display the node at the top of the Stack or at the front of the Queue

The node in this lab is either Employee_LastName object or TitleEmployee_LastName object.

-class Employee_yourLastname that maintains employee id, last name, first name, department and salary. The class Employee should have no-argument constructor, parameter constructor, mutator methods, accessor method and method toString to display the information of one employee

-class TitleEmployee_yourLastName that inherits from class Employee_yourLastName and has two more fields, title (supervisor, manager, etc) and bonus.

The method toString will print the same information of one employee plus the title and the bonus.

(UML) EmployeeStack -data:Employee[ ] -top: int -size: int +EmployeeStack() +EmployeeStack(int n) +push(Employee newNode): boolean +pop (): Employee +peek(): Employee +showAll(): void

(UML) EmployeeQueue -data:Employee[ ] -size: int -numOfNodes: int -front: int -rear: int +EmployeeQueue() +EmployeeQueue(int n) +enque(Employee newNode): boolean +deque(): Employee +peek(): Employee +showAll(): void

PART 2: Evaluate the expression OBJECTIVES After finish this lab you can:

-Apply the Stack to evaluate the infixed notation expression

REQUIREMENTS: Read an infixed expression from the keyboard or a file, for example, (1 + 2) * 4 3

Use two Stack structures to evaluate the expression (see the Instruction below) and print out the result in the following format, for example: (1 + 2) * 4 3 = 9

WHAT WE NEED TO KNOW TO DO THE PROGRAM -Review the generic class -Review about Stack structure

HOW TO DO THE LAB

-Write a class GenericStack that can apply for any data type. You can use the code of GenericStack in the book for your reference (You do not need GenericNode and deepCopy for this lab)

-Write a controlling class (driver class) named SP2017LAB4_InfixedExpressionEvaluation_yourLastName that has at least two user defined functions, the method oneOperationProcess and the method oneExpressionProcess

User Defined function oneOperatorProcess

This method accepts two paramenters, Integer Stack and Character Stack In the body of the method 0neoperatorProcess

-pop the top operator in the stack of operators

-pop the two operands on the top of stack of operands

-Depend on the operator, calculate the result and push the result back to the stack of operand. The result is calculated with operand1, operand2 and operator that are popped from stack of operands and from stack of operators

User Defined function oneExpressionProcess that hold all the code to evaluate one expression METHOD main

-In the method main: display the menu to allow users can choose where the input expression is from, the keyboard or a file

-Define one Integer Stack that is used to store the integer operands

-Define one Character Stack that is used to store the operators ( + - * / or )

-Read one infixed expression from the keyboard or a file

-Using StringTokenizer or split of String to split input expression into the tokens (operands and operators) and store them to stack of operands and stact of operators by applying the following rules:

phase1: Scanning expression (read expression)

The program will scan the expression from left to right to extract operands, operators and the parenthesis

If the extracted item is a number, push it to the stackForOperands

If the extracted item is a + or operator: - check if the stackForOperators is empty, push it into the stack

- if the stackForOperators is not empty, process all the operators (+, -, *, / ) in the stackForOperators from top one by one until there is no operator (+, -, * or /) at top then push the extracted operator to stackForOperators

If the extracted item is a * or / operator: - check if the stackForOperators is empty, push it into the stack

- if the stackForOperators is not empty, process all the operators (*, / ) in the stackForOperators from top one by one until there is no operator (* or /) at top then push the extracted operator to stackForOperators

If the extracted item is an open parenthesis (, push it to stackForOperators

If the extracted item is an close parenthesis ), process all operators in the stackForOperators from the top until top is an open parenthesis (; then pop the open parenthesis ( off from the stackForOperators

phase2: Clearing stack

Process all the operators left in the stackForOperators from top until stackForOperators is empty

Display the result as the required format: The final result will be the last number in the stackForOpereands

(Any help would be great )

objectives: After finishing the lab4 part you can -handle the stack structure when applying push and pop operations to add or fetch and delete the nodes -handle the queue structure when applying enque and deque operations to add or fetch and delete the nodes Requirement statement: Develop the pseudo-code and draw the uML of data type classes of the project named create the project SP2017LABA PART1 that using the Restricted Data structure (Em or Employeeaueue) and the driver class Employee) should be SP2017LAB4 RestrictedstructureDemoWith The Employeestack or Employee Queue will keep employees or employees with title The application will allow users to select to work with either stack or aueue. When finishing with one, the application users want to exit allow users to continue to select and work with the other structure un following steps in order. For Stack or Queue, do the 1. ne the structure 2. Allow users to insert 5 nodes either Employee or TitleEmployee) 3. Show all 5 employees/titleEmployees that are inserted 4, Delete 2 nodes Queue 5. Display the node at the top of the stack or at the front of the The nade in this lab is either Employee Last Name object or TitleEmployee LastName object -class Employee e that maintains employee id, last name, first name, department and salary, The class murata method and method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

What are the structures and functions of the limbic systempg12

Answered: 1 week ago

Question

1. Organize and support your main points

Answered: 1 week ago

Question

3. Move smoothly from point to point

Answered: 1 week ago

Question

5. Develop a strong introduction, a crucial part of all speeches

Answered: 1 week ago