inherit from Manager.
Added by Amanda W.
Close
Step 1
Step 1: Identify the attributes and methods of the Manager class that need to be inherited. Show more…
Show all steps
Your feedback will help us improve your experience
Sri K and 74 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
SAMPLE CODE:- //ASMCNT JOB 1,NOTIFY=&SYSUID //CMPLNK EXEC HLASMCLG //C.SYSIN DD * ADD TITLE 'contest program' ADD CSECT ADD AMODE 31 ADD RMODE 24 * *--------------------------------------------------------------------* * * * register equates * * * *--------------------------------------------------------------------* * R0 EQU 0 register 0 BASEREG EQU 12 base register SAVEREG EQU 13 save area register RETREG EQU 14 caller's return address ENTRYREG EQU 15 entry address RETCODE EQU 15 return code EJECT * *--------------------------------------------------------------------* * * * standard entry setup, save area chaining, establish * * base register and addressibility * * * *--------------------------------------------------------------------* * USING ADD,ENTRYREG establish addressibility B SETUP branch around eyecatcher DC CL8'ADD' program name DC CL8'&SYSDATE' program assembled date SETUP STM RETREG,BASEREG,12(SAVEREG) save caller's registers BALR BASEREG,R0 establish base register DROP ENTRYREG drop initial base register USING *,BASEREG establish addressibilty LA ENTRYREG,SAVEAREA point to this program save area ST SAVEREG,4(,ENTRYREG) save address of caller's save * area ST ENTRYREG,8(,SAVEREG) save address of this program * save area LR SAVEREG,ENTRYREG point to this program savearea EJECT * *--------------------------------------------------------------------* * * * program body * * * *--------------------------------------------------------------------* OPEN (PRTLINE,OUTPUT) Open output file MVC LINE(26),MSGX PUT PRTLINE,LINE MVC LINE,BLANK LOOPINIT DS 0H SR 2,2 Clear reg 2 L 2,=F'20' Store 10 in reg 2 L 3,=F'1' Store 1 in reg 3 * LOOP DS 0H * CVD 3,PACKAREA Convert to decimal, store in packarea UNPK OUT,PACKAREA Convert to printable, store in out MVC LINE(8),OUT Move characters from out to line MVZ LINE+7(1),LINE Move zone bits PUT PRTLINE,LINE Put line in output file A 3,=F'1' Add 1 to current total in reg 3 * BCT 2,LOOP Subtract 1 from reg 2, if not zero * then go to LOOP label CLOSE (PRTLINE) Close output file * *--------------------------------------------------------------------* * * * standard exit - restore caller's registers and * * return to caller * * * *--------------------------------------------------------------------* * EXIT DS 0H halfword boundary alignment L SAVEREG,4(,SAVEREG) restore caller's save area addr L RETREG,12(,SAVEREG) restore return address register LM R0,BASEREG,20(SAVEREG) restore all regs. except reg15 BR RETREG return to caller EJECT * *--------------------------------------------------------------------* * * * storage and constant definitions. * * print output definition. * * * *--------------------------------------------------------------------* * LINE DS 0CL80 DC C' ' DC CL79' ' PRTLINE DCB DSORG=PS,DDNAME=PRTLINE,MACRF=PM, X RECFM=FB,LRECL=80 SUM DC P'01' ONE DC P'01' TOT DS PL2 OUT DC X'4040404040404040' MSGX DC CL26'Hi! I can count very fast.' BLANK DC CL80'' PACKAREA DS CL8 SAVEAREA DC 18F'-1' register save area END ADD //G.PRTLINE DD DSN=&SYSUID..OUTPUT(MYOUTPUT),DISP=SHR OUTPUT :- Hi! I can count very fast. 00000001 00000002 00000003 00000004 00000005 00000006 00000007 00000008 00000009 00000010 00000011 00000012 00000013 00000014 00000015 00000016 00000017 00000018 00000019 00000020 QUESTION :- 1. Upload the sample to your PDS IBM dataset JCL as member name ASMPGM in your JCL dataset. 2. SUBMIT it so that it will execute correctly (return code 0). It will create a member called MYOUTPUT in your OUTPUT dataset. Screen print the member ASMPGM in your JCL PDS. Also print out the member MYOUTPUT in your OUTPUT dataset. The expected result in MYOUTPUT will be: Hi! I can count very fast. 00000001 00000002 00000003 00000004 00000005 00000006 00000007 00000008 00000009 00000010 00000011 00000012 00000013 00000014 00000015 00000016 00000017 00000018 00000019 00000020 3. Now modify your program to reduce the count to 11 and print out a message at the end in caps - THIS IS MY FINAL ASSIGNMENT. 4. Screen print the modified source program ASMPGM in your JCL dataset and the MYOUTPUT member in your OUTPUT dataset.
Sri K.
Program #6 Binary Search Trees (Please write in JAVA!) Objectives Write and use a linked implementation of a binary search tree. Problem Description In this assignment, you will practice solving a problem using a binary search tree. You will implement a Java application that could be used in a restaurant. You are asked to implement four classes: MenuItem, BSTNode, BST and Driver. Each of these classes is described below. Classes The method names, parameters and return types must match the specification exactly. You may add other methods if you wish. MenuItem Class The MenuItem class represents one item ordered from a menu. The MenuItem has three instance variables: name (of type String), qty (of type int) and price (of type double). Implement the following methods for the MenuItem class: A constructor to initialize all instance variables. A value for each instance variable will be passed as a parameter to the constructor. The parameters must be in the order (name, qty and price). The instance variable name will be used as the search key and as the instance variable that will determine the order in which the items are stored in the binary search tree. Getters for all instance variables. Setter methods for each instance variable. equals(): Implement the equals() method for your MenuItem where two MenuItems are considered equal when they have the same search key (name). Other instance variables must be ignored. Use the standard signature for the equals() method. Note that, the equality of String attributes should be case insensitive. For example, “MATH”, “math” and “Math” match each other. In order to compare strings in Java use the String's equalsIgnoreCase() method. For example, the following code should print true: String str1 = "Hello"; String str2 = "hello"; System.out.println(str1.equalsIgnoreCase(str2)); toString(): a method that returns a nicely formatted string description of the item. All items should be separated by tabs (use " ") and the entire MenuItem should be displayed on one line. In addition to name, price and qty, calculate the total value of the MenuItem (price * qty) and add it to the end of the string. Rice $1.50 3 $4.50 Use the NumberFormat or DecimalFormat class to display prices with exactly two digits following the decimal place. Implement the Comparable interface and the compareTo() method for MenuItem. compareTo() returns a negative number when the invoking object's search key (name) is less than the parameter's search key 0 when the two search keys (names) are equal a positive number when the invoking object's search key (name) is greater than the parameter's search key For example, "Ant".compareTo("bat") will return a negative number. Note that the comparison of String attributes should be case insensitive. For example, “MATH”, “math” and “Math” match each other. Base the comparison only on the search key. All other instance variables must be ignored. BSTNode Class Create a BSTNode class. You must create your own BSTNode class and you may not use any node classes from the Java library. The BSTNode instance variables consist of data and two links, left and right. The data instance variable must be of type MenuItem. The instance variables must be private. Implement a constructor with parameters data, left and right, in that order. Implement getters and setters for all instance variables. Your Tree class must be separate from your BSTNode class. You may implement a generic BSTNode class if you like. BST Class The MenuItems data must be stored in a recursive binary search tree data structure. This means the data is stored in order according to the binary search tree principles. You must create your own binary search tree class (separate from the BSTNode class) and implement the recursive methods you need. You must create your own BST class and you may not use any tree classes from the Java library. Be sure to implement encapsulation by having a clean separation between the node and binary search tree classes. Do this by making the instance variables private in both classes and by putting methods that manipulate more than one node in the BST class. Use a linked implementation. The BST class will have one private instance variable, root, which will hold a reference to the topmost node in the tree. The BST class methods must include these recursive methods: A no-arguments constructor that instantiates an empty binary search tree. void insert(MenuItem mi): a method that takes one input parameter, a MenuItem, and adds it to the binary search tree in the proper spot, preserving the binary search tree property. If the MenuItem is already in the tree, insert() will not add a new item to the tree but rather will increment the qty of the existing item by the new qty. If the MenuItem is not already in the tree, the method inserts the MenuItem in its correct position void preorder() – traverses the tree in pre-order (based on the search key) and prints the contents of each Node void postorder() - traverses the tree in post-order (based on the search key) and prints the contents of each Node void inorder() - traverses the tree in post-order (based on the search key) and prints the contents of each Node size(): a method that returns the number of nodes in the tree int depth(): returns the height (depth) of the tree. Note: An empty tree has a height of -1. A tree with one node has height of 0. getTotalQty(): an integer method that sums and returns the quantities of all MenuItems in the Tree MenuItem search(String name) – traverses the tree and returns a reference to a MenuItem with a search key (name) that matches the parameter. Returns null if not found. getTotalBeforeTax(): a method that calculates and returns the total value of all items in the tree. Remember to multiply the price by the quantity to get the total for each item. getTax(): a method with one parameter, taxRate (a double). getTax() calculates and returns a double representing the tax to be paid on the order getTip(): a method with one parameter, percentage (a double). getTip() calculates and returns a double representing the tip to be paid on the order's total before tax. toString(): a method that returns a string representation of all the MenuItems in the tree. The items will be displayed in alphabetical order. The String includes the following: a restaurant name and some header lines details of all the MenuItems, one per line the total of all the items in the tree before tax and tip been added the amount of tax to be added (use a fixed rate of 8%) the amount of tip to be added (use a fixed rate of 20%) the total after tax and tip have been added Sample of String returned from toString(): Downtown Cafe --------------------------------------------------- Item Price Qty Total --------------------------------------------------- Injera $2.50 1 $2.50 Rice $1.50 3 $4.50 Sambusa $5.80 4 $23.20 Sushi $8.25 2 $16.50 --------------------------------------------------- Total: $46.70 Tax: $3.74 Tip: $9.34 --------------------------------------------------- Grand total: $59.78 You are required to use the approach outlined in class with a public method with no arguments (one argument in the case of insert(), search(), getTax() and getTip()) and a private helper method. You may *not* directly access the root of the tree from the driver. You may *not* implement a public getRoot() method. With the exception of inorder(), preorder() and postorder(), the Tree class should not contain any print statements. All printing occurs in the Driver. Driver Use the Driver class to demonstrate that the BST class and its methods work properly. Create one or two BST trees. Add 20 to 25 MenuItems to the trees. Change the order of insertion to test different tree topologies. Do not add the items in alphabetical order or your tree will degenerate to a linked list. Call all the BST methods and display the results. Be sure to test the case where the MenuItem is already been in the tree (insert() causes the existing item's quantity to be changed). Print both orders in a nicely formatted output.
Expected Output: The following screenshot is an example of output for a StudentV3 object. The class contains two methods to calculate the average of two grades and the difference between the grades. Your output will differ based on the object you define.
Akash M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD