c) Based on the following program segment, draw the representation of stack A, B and C...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
c) Based on the following program segment, draw the representation of stack A, B and C after the execution of the line of codes as indicated by Structure-A1, Structure-B1, and Structure-C1 respectively. In the diagram of the stack representation that you have drawn, you are to indicate the base and the top of the data. After that, show the output the program. Hint: A, B and C are the instances of a Stack data structure to store String object. Stack A = new Stack(); Stack B = new Stack (); Stack C = new Stack(); A.push("1"); A.push("a".toUpperCase()); A.push("u".toUpperCase()); A.push("t"); A.push("x"); A.push("e".toUpperCase()); A.push("t"); //** while (!A.isEmpty()) { ***Structure-A String s A.pop(); System.out.print(s+ " "); switch (s.toLowerCase()) { case "a": case "e": case "i": case "O": case "u": B.push(s.toLowerCase()); break; default: } C.push(s.toUpperCase()); **********Structure-B **********Structure-C System.out.println(); while (!B.isEmpty()) { String s B.pop(); System.out.print (s+ " "); System.out.println(); while (!C.isEmpty()) { String s = C.pop(); System.out.print(s+ " "); (10 marks) c) Based on the following program segment, draw the representation of stack A, B and C after the execution of the line of codes as indicated by Structure-A1, Structure-B1, and Structure-C1 respectively. In the diagram of the stack representation that you have drawn, you are to indicate the base and the top of the data. After that, show the output the program. Hint: A, B and C are the instances of a Stack data structure to store String object. Stack A = new Stack(); Stack B = new Stack (); Stack C = new Stack(); A.push("1"); A.push("a".toUpperCase()); A.push("u".toUpperCase()); A.push("t"); A.push("x"); A.push("e".toUpperCase()); A.push("t"); //** while (!A.isEmpty()) { ***Structure-A String s A.pop(); System.out.print(s+ " "); switch (s.toLowerCase()) { case "a": case "e": case "i": case "O": case "u": B.push(s.toLowerCase()); break; default: } C.push(s.toUpperCase()); **********Structure-B **********Structure-C System.out.println(); while (!B.isEmpty()) { String s B.pop(); System.out.print (s+ " "); System.out.println(); while (!C.isEmpty()) { String s = C.pop(); System.out.print(s+ " "); (10 marks)
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
On a Balance Sheet, identify whether each of the following items should be categorized under Assets or Liabilities. 0000 Assets Liabilities Cash Inventory Accounts Receivable Loans Accounts Payable...
-
123 Compare the purely graphical properties of these two notations, and the ways in which the graphical properties of each display correspond to the information structure being defined. Describe...
-
Cadmium is a highly toxic substance with lethal effects on the human body in concentrations greater than 4.4 x 10-mol/L. Cadmium (II) carbonate has a Kp of 5.2 x 10-12 at 25C. Calculate the...
-
Rigina Fibreboard makes roof liner for the automotive industry. The manufacturing manager is concerned about product quality. She suspect that one particular defect, tears in the fabric, is related...
-
As part of a study to determine factors that may explain differences in animal species relative to their size, the following body masses (in grams) of 50 different bird species were reported in the...
-
What is the drawback of the coefficient?
-
Chipcity Inc. is a fast-growing manufacturer of computer chips. Direct materials are added at the start of the production process. Conversion costs are added evenly during the process. Some units of...
-
Given the triangle below, find the angle 0. 10 9 Give your answer in degrees rounded to the nearest tenth. Do not include the degree symbol in your ans Provide your answer below:
-
A mechanism by which CPU control is transferred from one process to another.
-
This company is planning to invest in a project called Ellayiah . The management accounting department received the following information Capex $45000 Project period 5years Revenue $19000 Supplies...
-
The XYZ Co. incurred the following cost for the month of June 2019. XYZ accrues payroll monthly and pays payroll on the fifth of the following month. Direct manufacturing labor cost P80,000 Indirect...
-
A new product marketing push is being contemplated by Vanek Co. Fixed costs to be incurred are $700,000 for production of 80,000 units or less and $1,000,000 for more than 80,000 units. The...
-
The following information was extracted from the first year absorption-based accounting records of Enigma Corporation Total fixed costs incurred P100,000 Total variable costs incurred 50,000 Total...
-
The trial balance of Lumumba Traders at 30 June, 2020 is as follows: Shs.Shs. Equipment at cost42,100 Provision for depreciation of Equipment 1.7.201926,765 Inventory 1.7.20195,870 Accounts...
-
Workman Software has 10.6 percent coupon bonds on the market with 17 years to maturity. The bonds make semiannual payments and currently sell for 108.1 percent of par. a. What is the current yield on...
-
Planning: Creating an Audience Profile; Collaboration: Team Projects. Compare the Facebook pages of three companies in the same industry. Analyze the content on all available tabs. What can you...
-
Study the format of the analysis of variances in Exhibit 12-12. Suppose production is 156,000 units. Also assume the following: Other data are as shown in Exhibit 12-12. Prepare an analysis of...
-
The following questions are based on the data contained in Exhibit 12-9. 1. Suppose actual production and sales were 8,000 units instead of 7,000 units. (a) Compute the sales-volume variance. Is the...
-
Belfair Kayak Company makes molded plastic kayaks. Standards costs for an entry-level whitewater kayak are: Direct materials, 60 kilograms @ $5.50 per kilogram Direct labour, 1.5 hours $16 per hour...
Study smarter with the SolutionInn App