The following is a program using Stack. 1 import java.util.Stack; 2 3 public class StackApp {...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The following is a program using Stack. 1 import java.util.Stack; 2 3 public class StackApp { 345 6 7 8 9 10 11 12 13 14 15 16 234567 17 18} a) b) public static void main(String args[]) { Stack<Integer> st = new Stack<>(); Integer[] x = { 4, 5, 6, 2, 9, 5, 1, 4, 1, 3}; for (int i=0; i<x .length; i++) } st.push(x[i]); for (int j 0; j<3; j++) System.out.print(st.pop()); System.out.println(); System.out.println(st. peek()); for (int k=0; k<3; k++) st.pop(); System.out.println(st.pop()); Specify the output of lines 10 and 11. Specify the output of line 13. Specify the output of line 16. // Question (a) // Question (b) // Question (c) The following is a program using Stack. 1 import java.util.Stack; 2 3 public class StackApp { 345 6 7 8 9 10 11 12 13 14 15 16 234567 17 18} a) b) public static void main(String args[]) { Stack<Integer> st = new Stack<>(); Integer[] x = { 4, 5, 6, 2, 9, 5, 1, 4, 1, 3}; for (int i=0; i<x .length; i++) } st.push(x[i]); for (int j 0; j<3; j++) System.out.print(st.pop()); System.out.println(); System.out.println(st. peek()); for (int k=0; k<3; k++) st.pop(); System.out.println(st.pop()); Specify the output of lines 10 and 11. Specify the output of line 13. Specify the output of line 16. // Question (a) // Question (b) // Question (c)
Expert Answer:
Answer rating: 100% (QA)
a The output of line 10 will be 951 popped elements from the stack in ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Runner A is initially 5 . 0 mi west of a flagpole and is running with a constant velocity of 3 . 0 mi / h due east. Runner B is initially 2 . 0 mi east of the flagpole and is running with a constant...
-
Refer to Exercise 2.3 and the data on extracurricular activities. Find the sample mean and standard deviation. In Exercise 2.3 l5 0 1 4 3 0 2 1 6 1 1 0 0 2 0 0 3 1 2 1 2 2 2 2 2 1 0
-
D is a one-third general partner in the DEF partnership. Both D and the partnership are cash method, calendar year taxpayers. D dies at a time when the partnership has earned $15,000 for the current...
-
Question 5 [ 4 points ] In the table shown below is accounting equation information as it applies to Second Time Around Clothing. Calculate the missing amounts assuming that a . Assets decreased by $...
-
Two identical 1.00- wires are laid side by side and soldered together so they touch each other for half of their lengths. What is the equivalent resistance of this combination?
-
What return would Trey (from Problem 8) receive if he had purchased the stock for cash? Trey purchases 200 shares of Turner stock for $40 per share. Trey pays $4000 in cash and borrows $4000 from his...
-
Using only the factor formulas given in Table 2.6, derive Equation 7.6 starting with Equation 7.3. TABLE 2.6 Summary of Discrete Compounding Interest Factors. To Find Given Factor Symbol Name P F...
-
Preston Recliners manufactures leather recliners and uses flexible budgeting and a standard cost system. Preston allocates overhead based on yards of direct materials. The company's performance...
-
The buyer at Ajax Co. is responsible for maintaining inventory of a key component which is used in the firm's manufacturing process throughout the entire 52-week year. The annual demand is 12,000...
-
A slab of polymer 1.6 cm thick, originally at 30C, is heated between steel plates with a surface temperature of 70C. The density of the solid is 950 kg/m 3 , its thermal conductivity is 0.12 W/m K,...
-
A$201,400 mortgage for 15 years for a new home is obtained at the rate of 9.1% compounded monthly. Find (a) the monthly payment, (b) the interest in the first payment, (c) the principal repaid in the...
-
Price per TV Quantity Demanded per Month Quantity Supplied per Month $800 2,000 12,000 750 3,000 11,000 700 4,000 10,000 650 5,000 9,000 600 6,000 8,000 550 7,000 7,000 500 8,000 6,000 450 10,000...
-
X Inc. and Y Inc. are virtually identical companies with identical cost structures and very similar business practices operating in the same lines of business. X Inc. is a public company based in...
-
4. If an element in a binary heap is stored in an array at position i and the root is at position 0, a) where is the parent stored? b) where are two children stored?
-
Which banks are currently listed as too big to fail, B) who regulates these banks, and C) what is the name of the supervisory program?
-
What is the size of a small, medium and large company, and their budget size or money allocated to Information Security?
-
1. What is monogenism? Why is it important for our understanding of the human race? 2. According to our lecture, there are 2 ways to order life (put it in a hierarchy). What are these 2 ways, and...
-
Three forces with magnitudes of 70pounds, 40 pounds, and 60 pounds act on an object at angles of 30, 45, and 135, respectively, with the positive x-axis. Find the direction and magnitude of the...
-
Harold Conners (Social Security number 785-23-9873) lives at 13234 DeMilo Drive, Houston, TX 77052, and is self-employed for 2012. He estimates his required annual estimated tax payment for 2012 to...
-
Dr. George E. Beeper is a single taxpayer. He lives at 45 Mountain View Dr., Apt. 321, Spokane, WA 99210. Dr. Beeper's Social Security number is 775-88-9531. Dr. Beeper works for the Pine Medical...
-
On February 2, 2012, Alexandra purchases a personal computer for her home. The computer cost $3,000. Alexandra uses the computer 80 percent of the time in her accounting business, 10 percent of the...
-
Explain why the business objectives of owners and managers are likely to diverge. How might owners attempt to ensure that managers act in their interests and not in the managers own interests?
-
1. In what ways did the defence industries respond to the ending of the Cold War? 2. Using an Internet search, find out how the defence and security industries have responded to the threat of...
-
What is the Standard Industrial Classification (SIC)? In what ways might such a classification system be useful? Can you think of any limitations or problems such a system might have over time?
Study smarter with the SolutionInn App