Order Grade A+ Academic Papers Instantly!

Computer Science homework help

Computer Science homework help.  
 
 
 
COSC2436 – LAB4
Table of Contents
TITLE: 1
Time to complete. 1
COURSE OBJECTIVES – LEARNING OUTCOME. 1
LAB OBJECTIVES. 2
SKILL REQUIRED TO DO THIS LAB. 2
HOW TO DO  EACH PART. 2
LAB 4 PART 1. 3
LAB4 PART2. 4
HOW TO TURN IN THE LAB. 4
HOW TO GRADE THE LAB. 4
 
 
 
Note: in the instruction of the lab change “yourLastName” to your last name
 

TITLE:

Restricted Structure – Evaluate the Expression
 
Time to complete:
Two weeks
 

COURSE OBJECTIVES – LEARNING OUTCOME

 
[LO1]
Provide UML class diagram and the code of data type classes
Provide the pseudo-code or flowchart based on the requirement of a project before writing the code of the driver class. Also, can access data members of data type classes
Describe and implement the inheritance relationship between super class and child classes.
Can use abstract classes or interface and apply polymorphism to the real-life problem project
 
[LO2]
Describe and implement operations of unsorted/sorted array-based structures
 
[LO11]
Determine BigO of each operation algorithm
Calculate Density of each data structure type
Evaluate and compare the performance of operations of each type of data structures
 
[LO3]
Describe and implement operations of Stack and Queue structures. Using Stack/Queue to the real life problem project
 
 

LAB OBJECTIVES

-Create a new project, add source file to the project, compile and run the program without errors and qualified to the requirement
-Declare variables of int, double, String;
-provide UML of data types
-Create data types with data members, constructors, mutator methods
-Apply Inheritance relationship
-Apply polymorphism in the project
-provide the pseudo-code of program
-create and manage the menu to loop back to re-display after each task: using do.. while
-Use switch statement to determine and define the action for each task
-Format the output in columns and double numbers with 2 decimal digits
-Display message box
 
NEW CONCEPTS
-Can create the data structure type of Stack and Queue
-Can implement push/enqueue nodes, peek, pop/dequeue and show all nodes with Stack/Queue
 

SKILLS REQUIRED TO DO THIS LAB

Review all skills required from the previous labs and focus on the following:
-Draw UML of data type classes
-Write pseudo-code or draw flowchart of algorithm
-Create a data type class with data members, constructors, mutator accessor methods, toString
-Declare an object in main(), how to access the methods of data type classes from main()
-control structure: if..else, switch, do..while loop
-How to set the decimal digits (2) of decimal numbers
 
-How to write the code to describe Inheritance relationship between child classes to parent class: How to inherit data members, constructors or methods from the parent class
-How to apply polymorphism technique to the project.
 
NEW SKILLS:
-Learn how to create the data structure of type Stack and of type Queue
-Learn the algorithms of the operations, push and pop of Stack – enque and deque of Queue to see how the process work. Also, learn how to access these operations to insert, remove the node
-Learn how to fetch the node from Stack and Queue by writing the method peek()
-Learn how to show all the nodes in the Stack or Queue by writing the method showAll()
-Learn how to write the generic code and apply to write the code for a generic stack
-Learn how to declare an object of a generic class with specific data type d
 

HOW TO DO  EACH PART

From now and on yourLastName will be changed to your last name
 
*Step1: Read the requirement of each part.
Provide the UML of class Account_yourLastName, class CheckingAccount_yourLastname, class SavingAccount_yourLastName
Provide the pseudo-code or flowchart of main()
 
*Step2:
-start editor eclipse, create the project with the project name:
SP2020_LAB4PART1_yourLastName (part 1)
SP2020_LAB4PART2_yourLastName (part 2)
-add data type classes:
Account_yourLastName.java (part 1)
CheckingAccount_yourLastName.java (part 1)
SavingAccount_yourLastName.java (part 1)
-add data structure classes
Stack_yourLastName and Queue_yourLastName (part 1)
GenericStack_yourLastName (part2)
-Add the driver class
SP2020_RestrictedStructureWithAccount_yourLastName (part1)
SP2020_EvaluatingInfixedExpression_yourLastName (part2)
 
 
*Step3: follow step by step in the pseudo-code to write the java code
Re-use the code of data type classes from lab3
Write the code of Stack_yourLastName and Queue_yourLastName (Part1) -using the code on the page 140
And page 160 in the text book for your reference
Write the code of GenericStack_yourLastName (part2) – Using the code on the page 165 in the text book
for your reference with the following notices:
Line 8: data = new T [100];
Line13: data = new T [n];
Line20: data[top] = newNode; (just for this lab)
 
Based on the pseudo-code write the java code of main() of the driver class
SP2020_RestrictedStructureWithAccount_yourLastName (part1) or SP2209_InfixedExpressionEvaluation_yourLastName (part2)
 
*Step4: compile and run the program
*Step5: debug if there are any errors to complete the program
 

LAB 4 PART 1

DATA TYPE CLASSES
-Reuse the class Account_yourLastName, CheckingAccount_yourLastName, SavingAccount_yourLastName from the previous lab
 
//This method should be added to Stack_yourLastName
public Account_Martinez peek()
{
if (top != -1)
{
return data[top].deepCopy();
}
return null;
}
 
//This method should be added to Queue_yourLastName
public Account_Martinez peek()
{
If (numberOfNode !=0)
{
return data[front].deepCopy();
}
return null;
}
 
DRIVER CLASS
Provide the pseudo-code or flowchart then write the code for the application SP2020_RestrictedStructureWithAccount_yourLastName that first display the following menu to select types of data structure, for example:
 
SP2020_RestrictedStructureWithAccount_Martinez.java
MAIN MENU – LUIS MARTINEZ

  1. Stack Structure
  2. Queue Structure
  3. Exit

 
FOR EACH TYPE OF RESTRICTED STRUCTURE DO THE FOLLOWING TASKS SEQUENTIALLY:
INSERT 3 NODES TO THE STRUCTURE
Ask for the information and read from the keyboard for either CheckingAccount or SavingAccount
For each one, insert the account to the data structure.
If Insert successfully display the message “Insert Account success”
Otherwise: display the message: “Insert Account failed”
 
DELETE 1 NODE
Remove the node at the top (Stack) or at the front (Queue)
If the node exists, display the information of the node; otherwise display the message: “There is no account in the data structure”
 
DISPLAY THE NODE AT THE TOP (Stack) / AT THE FRONT (Queue)
Display the node at the top (Stack) or at the front (Queue)
If the node exists, display the information of the node, otherwise display the message: “Stack is empty” or “Queue is empty”
 
SHOW ALL NODES
Display all the accounts currently stored in the data structure
You should re-display the menu to allow users to continue using your program until they want to exit
 
 
Requirement:
-You must change Martinez to your last name
-Change Luis Martinez to your full name
-Add the file name as the first comment line at the top of each class
-Get the output pictures of the part 1 and paste after the pseudo-code document
-write the comment on each part in both classes
 

LAB4 PART2

Create an application that can help users to evaluate the infixed expression
-Create a user-defined function to perform one operation that accepts stack for Operands and stack for Operators as two parameters
In this user-defined function, call pop() one time with the stack for Operators to have the operator and  call pop() two times from the stack of Operands to have two numbers
Depend on the operator, either +, -, * or / then calculate the result with two numbers
Push the result back to the stack of numbers (Operands)
 
-In the main(), first, display the menu to allow users select the method where to read the input expression:
 
SP2020_InfixedExpressionEvaluation_Martinez.java
MENU TO SELECT WHERE TO READ INPUT

  1. Read one Expression from the keyboard
  2. Read expressions from an input file
  3. Exit

 
CASE 1: //input from the keyboard
Reading one expression from the keyboard as a string
 
Do the following algorithm for one expression that include: create 2 stacks, split the expression into tokens, phase 1, phase 2 and display the result:
 
CREATE TWO STACKS: One stack is used to store Operands (Integer) and one stack is used to store Operators (Character)
 
SPLIT THE EXPRESSION INTO TOKENS
-Using StringTokenizer to split the string of expression into the tokens (either they are operands or operators)
 
PHASE1: Read each token of the expression from left to right and store them to stack of operands (Integer) and stack of 6 operators: + – * / (  ) by applying the following rules:
 

  • if the token is a number, push it to the stack for Operands (Integer)
  • if the token is AN OPEN PARENTHESIS ”(“, push it to the stack for Operators (Character)

 

  • if the token is AN CLOSE PARENTHESIS “)”, do the following:

Create a loop, access the above user-defined function to perform one operation until the top of stack of Operators is the OPEN PARENTHESIS “(”, then pop it off
 

  • if the token is one of 2 operators + or – , do the following:

if the stack for operators is empty, push it in
if the stack for operations is not empty, Check the top of stack for Operators:
–if the top is one of 4 operators + – * / then call the above user-define function to calculate
–then push the operator (+ or -) in
 

  • if the token is one of 2 operators * or /, do the following:

if the stack for Operators is empty, push it in
if the stack for Operators is not empty, check the top of stack for operators:
–if the top is one of 2 operators * / then call the above user-defined function to calculate
–then push the operator (* or /) in
 
PHASE 2: clearing the stack for Operators

  • Create the loop to call the above user-defined function to calculate until stack for Operators is empty

DISPLAY THE RESULT FOR THE INPUT FROM THE KEYBOARD

  • The format of the output result as below, the expression is the input string and the result is the last number that is popped from the stack for Operands

Expression = result
For example, the output of the expression (25 + 63 – 12) * 20 – (8 * 12) is:
 
SP2020_InfixedExpressionEvaluation_Martinez.java
                                      EXPRESSION FROM THE KEYBOARD
                                      (25 + 63 – 12) * 20 – (8 * 12)   =   1424
 
CASE 2: //Input from the file
Read file name
Open input file (Input file can be downloaded from eCampus: file expression.txt)
Loop to read the file
Read each line of file as a string that is one expression
For each expression: Do the algorithm that is the same as we did for one expression read from the keyboard: create 2 stacks, split the expression into tokens, phase 1, phase 2 and display the result
 
DISPLAY THE RESULT FOR THE INPUT FROM THE FILE

  • The format of the output result as below, the expression is the input string and the result is the last number that is popped from the stack for Operands

The output should be:
 
                                      SP2020_InfixedExpressionEvaluation_Martinez.java
                                      EXPRESSION FROM THE INPUT FILE expressions.txt
                                      23 + 28 = 51
                                      64 * 25 = 1600
                                      14 + 25 – 12 = 27
                                      36 * 14 / 42 = 12
                                      25 + (12 + 34 * 23) = 819
                                      (25 + 63 – 12) * 20 – (8 * 12)   =   1424
 
 

HOW TO TURN IN THE LAB

Part 1: (you can zip whole part 1 folder into one .zip file to submit part1)
Pseudo-code of part 1
Account_yourLastName.java
CheckingAccount_yourLastName.java
SavingAccount_yourLastName.java
Stack_yourLastName.java
Queue_yourLastName.java
SP2020_RestrictedStructureWithAccount_yourLastName.java
 
Account_yourLastName.class
CheckingAccount_yourLastName.class
SavingAccount_yourLastName.class
Stack_yourLastName.class
Queue_yourLastName.class
SP2020_RestrictedStructureWithAccount_yourLastName.class
 
Part 2:
Pseudo-code of part 2
GenericStack_yourLastName.java
SP2020_InfixedExpressionEvaluation_yourLastName.java
 
GenericStack_yourLastName.class
SP2020_InfixedExpressionEvaluation_yourLastName.class
 
.

HOW TO GRADE THE LAB

 

HOW TO GRADE THE LAB Readings & Assignments
Turn in on time 3
PART1:
class Stack_yourLastName, class Queue_yourLastName
 
2
Data type class with inheritance 1
SP20220_RestrictedStructureDemo_yourLastName: handle menu in loop  
0.5
•      declare Stack, insert nodes, remove nodes, display top, showAll 2
•      declare Queue, insert nodes, remove nodes, display front, showAll 2
compile success, do all the requirement – polymorphism 2
comments 1
PART2
Class GenericStack
 
1
Class SP2020_InfixedExpressionEvaluation_yourLastName
Declare the stack of operators – Declare the stack of operands
 
1
Menu handle to allow users select keyboard or file or exit 0.5
Read expression from keyboard 0.5
Read expression from the file all lines 1
Use StringTokenizer or split to split the expression to tokens 1
User-Defined Function for one Operator Process 1
Function for one Expression Process method 1
phase 1 4
phase 2 1
Function of Display the result as required format 0.5
Compile successfully 3
comments 1
LAB 4 SCORES  30 POINTS

 
 
 
 

Computer Science homework help

Solution:

15% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!

Why US?

100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

Original Writing

We complete all papers from scratch. You can get a plagiarism report.

Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.